Skip to content
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

docs(gateway): record error source in example code #1989

Closed
wants to merge 2 commits into from

Conversation

vilgotf
Copy link
Member

@vilgotf vilgotf commented Nov 9, 2022

Value (required to record variables in events) has no impl<T: Error> Value for T, but does have a impl Value for dyn Error implementation. Recording values as Error exposes the error source in recorded events, which includes context.

It's important to use this for all public examples in Twilight since users will base their code on them, and not including error sources will lead to frustration when debugging.

@vilgotf vilgotf added the t-docs A change to the documentation label Nov 9, 2022
@github-actions github-actions bot added c-all Affects all crates or the project as a whole c-book Affects the book c-cache Affects the cache crate c-gateway Affects the gateway crate c-lavalink Affects the lavalink crate c-standby Affects the standby crate labels Nov 9, 2022
@vilgotf
Copy link
Member Author

vilgotf commented Nov 9, 2022

See tokio-rs/tracing#1308 for upstream discussion

@vilgotf
Copy link
Member Author

vilgotf commented Nov 9, 2022

tracing apparently lacks support for correctly recording errors (the Error::source method is ignored and it just uses the Debug implementation) so this PR is as of now completely wrong. https://lib.rs/crates/tracing-error seems like the official way to record errors (specifically the TracedError struct), this PR could transition to use that instead in the relevant examples.

@vilgotf vilgotf marked this pull request as draft November 11, 2022 06:29
@vilgotf vilgotf closed this Jan 14, 2023
@vilgotf vilgotf deleted the vilgotf/docs/gateway/log-error-source branch January 14, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-all Affects all crates or the project as a whole c-book Affects the book c-cache Affects the cache crate c-gateway Affects the gateway crate c-lavalink Affects the lavalink crate c-standby Affects the standby crate t-docs A change to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant