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
Prevent duplicated error information in "wrapping errors" example
The "Wrapping errors" example, which illustrates how to wrap errors, is
using the wrapped error in the text that is displayed as well as the
implementation of source(). In so doing it effectively duplicates the
error information. Such behavior does not play nice with error reporting
crates such as anyhow, eyre, and others that make use of both this data.
It is also questionable at best from a logical point of view, because,
as the name suggests, the source should be a lower level error that is
the cause of this one.
With this change we update the documentation, suggesting the usage of a
custom error string describing at a higher level what went wrong. To
keep the example simple, we did not include the actual string in the
error (a comment already suggests that this could be done), although
that probably should be done in real life to provide additional context.
An alternative approach would be to not return a source, but I figured
that it's sort of desired for the illustration of wrapping an error.
0 commit comments