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

Manually implement backtrace for custom error type #811

Closed
wants to merge 1 commit into from

Conversation

scottopell
Copy link
Contributor

What does this PR do?

Motivation

Before:

Error: SerdeYaml(Error("generator[0].unix_datagram.variant: invalid type: enum, expected any value", line: 7, column: 16))

After:

Error: WithBacktrace { inner: Wrapped(Error("generator[0].unix_datagram.variant: invalid type: enum, expected any value", line: 7, column: 16)), backtrace: Backtrace [{ fn: "lading::Error::bt", file: "./home/ubuntu/dev/lading/lading/src/bin/lading.rs", line: 79 }, { fn: "lading::Error::wrap", file: "./home/ubuntu/dev/lading/lading/src/bin/lading.rs", line: 74 }, { fn: "core::ops::function::FnOnce::call_once", file: "./rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs", line: 250 }, { fn: "core::result::Result<T,E>::map_err", file: "./rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs", line: 829 }, { fn: "lading::get_config", file: "./home/ubuntu/dev/lading/lading/src/bin/lading.rs", line: 268 }, { fn: "lading::main", file: "./home/ubuntu/dev/lading/lading/src/bin/lading.rs", line: 584 }, { fn: "core::ops::function::FnOnce::call_once", file: "./rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs", line: 250 }, { fn: "std::sys_common::backtrace::__rust_begin_short_backtrace", file: "./rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs", line: 154 }, { fn: "std::rt::lang_start::{{closure}}", file: "./rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs", line: 167 }] }

Related issues

A list of issues either fixed, containing architectural discussions, otherwise relevant
for this Pull Request.

Additional Notes

Anything else we should know when reviewing?

@scottopell
Copy link
Contributor Author

scottopell commented Feb 7, 2024

inspired by dtolnay/thiserror#257 (comment)

@scottopell
Copy link
Contributor Author

but none of this is getting merged, so closing for now.

@scottopell scottopell closed this Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant