1 unstable release
| 0.1.0 | Jan 15, 2019 |
|---|
#8 in #lark
90 downloads per month
Used in 13 crates
(10 directly)
52KB
1.5K
SLoC
Types for tracking errors through queries.
Here is how it works:
- Queries that can themselves report errors return
WithError<T>; the errors contained in that value were discovered during executing that query. - If another query uses the result of a query that returns
WithError, it can just useinto_valueto ignore the errors --WithErroralways includes some form of sentinel value that you can use (i.e., you can just ignore the errors and try to get on with life). - In the worst case, one can you
Result<T, ErrorReported>and haveErr(ErrorReported)act as a sentintel value for "failed to produce a value because of some error". This is not preferred because now downstream queries have to care whether you propagated an error or not, but sometimes it's the best/easiest thing to do.- To help with this, the
or_sentinel!query acts as a kind of?operator for bridging aResult<T, ErrorReported>into aUwhereUhas a proper sentinel -- if the result isErr(ErrorReported), it creates the error-sentinel forUand returns it. - This relies on the
ErrorSentineltrait, which defines the error-sentinel for a given type.
- To help with this, the
This scheme is not the most ergonomic and I would like to change it, but it will do for now. -nikomatsakis
Representation of an error in the Lark compiler.
For more information, see the main readme and internals doc.
Dependencies
~7–10MB
~204K SLoC