-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ErrorValue requires the wrapped error to be 'static #288
Comments
My lifetime-fu got rusty, but it might be that for object-safety, |
I made my own ErrorValue-like type that basically inlined the call to emit_error and used a |
Worked fine for what exactly? |
I was able to log the error using |
The Lack of support for error references is actually a regular pain point when using slog in middlewares to log errors. It prevents from logging the error and then passing it up the chain. You need to either clone the error (rarely implemented in the ecosystem unfortunately) or move ownership to Removing |
This commit adds the `ErrorRef` wrapper type. It enables to log error by reference, without moving ownership. It means that it is the non-owning counterpart of `ErrorValue`. Logging error references is an important use case for transparent logging middlewares. With this wrapper type, you can log the error and still pass it up the call stack. Such a wrapper type could already easily be implemented in user applications, but having it as part of Slog should help ergonomics. This also enables further improvements by integrating it with the Slog macros. Closes slog-rs#288
This commit adds the `ErrorRef` wrapper type. It enables to log error by reference, without moving ownership. It means that it is the non-owning counterpart of `ErrorValue`. Logging error references is an important use case for transparent logging middlewares. With this wrapper type, you can log the error and still pass it up the call stack. Such a wrapper type could already easily be implemented in user applications, but having it as part of Slog should help ergonomics. This also enables further improvements by integrating it with the Slog macros. Closes #288
The
ErrorValue
type wraps anyE: std::error::Error
to allow logging of the error and its source chain. But it requiresE
to also be'static
(as doesSerializer::emit_error
). There's no requirement for this bound, I can rewriteErrorValue
myself to work without it, so slog should get rid of it too.The text was updated successfully, but these errors were encountered: