3 ms·
It's technically feasible to add SpanTrace support to thiserror fairly easily (30 mins work - Issue: https://github.com/dtolnay/thiserror/issues/400 https://git
by joshka 2y ago
It's technically feasible to add SpanTrace support to thiserror fairly easily (30 mins work - Issue: https://github.com/dtolnay/thiserror/issues/400 https://github.com/dtolnay/thiserror/issues/400, PR: https://github.com/dtolnay/thiserror/pull/401 https://github.com/dtolnay/thiserror/pull/401). This would solve part of the problem in a way that is meaningfully good for that side of the ecosystem. I suspect you could probably do something similar for Snafu
- shepmaster 2y agoWithout deeply looking into it, I'd expect that to integrate with SNAFU, you could basically write something like this: struct SpanTraceWrapper(tracing_error::SpanTrace); impl snafu::GenerateImplicitData for SpanTraceWrapper { fn generate() -> Self { Self(tracing_error::SpanTrace::capture()) } } And then you can use it as #[derive(Debug, Snafu)] struct SomeError { #[snafu(implicit)] span_trace: SpanTraceWrapper, } This will capture the `SpanTrace` whenever `SomeError` is constructed (e.g. `thing().context(SomeSnafu)` or `SomeSnafu.fail()`.
- joshka 2y agoNeat :)