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
{{ message }}
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
Context can either be a cheaply constructed Fail or an extension to Error. It doesn't allow wrapping a struct that implements Fail.
This was more understandable when it felt like the focus was exclusively on using Error but now with the emphasis being on there being multiple workflows, this seems like shortcoming in the API.
The text was updated successfully, but these errors were encountered:
Naively, it'd be great to just make Context generic over a Fail. The problem is that Error isn't a Fail because of coherence problems.
Without resolving the coherence problem, either by waiting to break the API once specialization is available or by removing the From<Fail> for Error, this would probably require expanding the Either enum to a generic Fail. The problem with that is that Context would then have a useless generic parameter when used with Error.
This is an intentional design choice. The value of Context largely comes from the fact that you can wrap multiple kinds of errors together. If it had a parameter, this would not be true. Apologies for not explaining in more detail, but I explored down this path and found it added a lot of complexity to the APIs and to the recommended Error + ErrorKind pattern.
In contrast, if all you want to do is add some displayable info to a particular error type, the wrapper for that is not very difficult to write.
Moving this from reddit.
Context
can either be a cheaply constructedFail
or an extension toError
. It doesn't allow wrapping astruct
that implementsFail
.This was more understandable when it felt like the focus was exclusively on using
Error
but now with the emphasis being on there being multiple workflows, this seems like shortcoming in the API.The text was updated successfully, but these errors were encountered: