ITADN

Formatting / anyhow Conversion / implicit change_context

#8318Closedchrs-b 创建于 2026-01-24
area/libs > error-stackarea/libslang/rustcategory/enhancement
C
chrs-bcommented
### Related Problem I just started using error-stack and love it so far. With anyhow, I constantly forgot to add .context while error-stack enforces .change_context per layer. Also I was just using anyhow .context to identify source location, which is captured in error_stack::Report automatically. So far so good. A few questions tho: 1. Formatting I use tracing to log errors. In the output I see (even in my terminal, but also in captured logs) ``` \x1b[1mCoreDB\x1b[22m ``` => Is it possible to remove formatting (in this case italic) from the output? 2. Conversion from anyhow errors I do this with .into_report. What makes this a bit cumbersome is that this creates a Report<anyhow::Error>, while most fn.s return a Report<LocalError>, which means I need another .change_context call. => Is it possible, at least for simple error types like `struct MyError;`, to integrate both steps? 3. Adding a context Adding a context with .change_context is straight forward. However, at least for simple error types, is there a way to do this automatically without calling .change_context? I cannot implement `impl From Report<SubModError> for Report<AnotherModError>` because Report is not defined in my crate... => Is there a way, at least for simple error types, to add a context implicitly without calling .change_context? Cheers, Chris ### Proposed Solution For configuring formatting it would be great to add an API for that purpose. ### Alternatives _No response_ ### Additional context _No response_
关闭于 2026-01-29 1 条评论