You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea is that you really have two classes of errors
local errors - expected in normal operation. usually handled 'locally'
global errors- some serious issue that should not occur during normal operation. These should generally be propagated all the way up
The idea is to 'double-wrap' the Results such that the inner Errors encode 'local' errors (such as validation errors), while the outer Errors encode 'showstoppers' (such as IO errors).
The downside is the error types get a little ugly (Result<Result<T, LocalError>, GlobalError>).
the upside is that in calling code, a consumer of the error can use '?' to propagate and unwrap the global error upwards, and explicitly handle the so-called local error with a match statement.
The text was updated successfully, but these errors were encountered:
the error handling can be improved.
taking inspiration from
The idea is that you really have two classes of errors
The idea is to 'double-wrap' the
Result
s such that the innerError
s encode 'local' errors (such as validation errors), while the outerError
s encode 'showstoppers' (such as IO errors).The downside is the error types get a little ugly (
Result<Result<T, LocalError>, GlobalError>
).the upside is that in calling code, a consumer of the error can use '
?
' to propagate and unwrap the global error upwards, and explicitly handle the so-called local error with amatch
statement.The text was updated successfully, but these errors were encountered: