Comments (5)
miette does have backtrace printing/hook capabilities for panics. What I'm looking for is support for printing backtraces from backtrace fields in errors. From thiserror
docs:
anyhow
then looks for these provided backtraces and prints them. From the anyhow
docs:
from miette.
@zkat I've been working on some basic backtrace stuff with miette as a library user, but I could try to adapt it into a proper feature at some point.
backtrace code I pulled directly from human-panic, which is also what eyre uses last I checked: https://github.com/cloudtruth/cloudtruth-cli/blob/8ba6b5a4bfde7684cbeac128f68fa4f4f4366408/crates/integration-test-harness/src/backtrace.rs#L13
And then I created a very basic Diagnostic for panic messages with an optional backtrace: https://github.com/cloudtruth/cloudtruth-cli/blob/8ba6b5a4bfde7684cbeac128f68fa4f4f4366408/crates/integration-test-harness/src/panic.rs#L55
What do you think the best approach is for adding something like this to the library? Something similar to eyre does it where it just checks for RUST_BACKTRACE and RUST_SPANTRACE? Also a fancier backtrace renderer is probably in order.
from miette.
The use case with backtraces that I built on top of miette is to actually show source code from failing unit tests. To do this I use track_caller
to find the source file of the code that installed the panic handler, and then search the backtrace for the first frame matching that directory path. See https://github.com/cloudtruth/cloudtruth-cli/blob/8ba6b5a4bfde7684cbeac128f68fa4f4f4366408/crates/integration-test-harness/src/source_span.rs#L75
The install function is called on each test from a #[use_test_harness]
attribute that I wrote.
Maybe this could be a second crate that someone could choose to pull in if they're specifically wanting better cargo test reports?
from miette.
Made some improvements on my previous version of panic reporting by using actual Diagnostics sources instead of ad-hoc cause chains. So now there's a root Panic
report and then a PanicLocation
report on top of it if the panic location is available. See code here
Output example with backtrace:
without backtrace:
from miette.
here's miette's panic hook stuff: https://github.com/zkat/miette/blob/main/src/panic.rs
from miette.
Related Issues (20)
- Compile to wasm32-unknown-unknown / Compile without `terminal_size` HOT 4
- Errors with zero-length span and no context lines are mostly pointless HOT 1
- 要是错误提示能使用中文输出就好了! HOT 5
- Failing tests with `--all-features` HOT 1
- Feature request: output an error as `json::Value` or `serde_json::Value` directly HOT 2
- Feature request: Span line limit for diagnostics HOT 3
- Help: Sub Errors HOT 3
- Is there a reason that `Report` doesn't implement `Error` and `Diagnostic`? HOT 2
- Converting a `Report` to a `Box<dyn Diagnostic>` wipes all `Diagnostic` information HOT 1
- Improve compilation speed by reducing expanded llvm lines HOT 4
- Add `#[cold]` to some of the constructor functions HOT 3
- `#[label]` derive doesn't seem to work with `Option<T>` where `T` implements `Into<SourceSpan>` but not `Copy`
- NO_COLOR is printing ansi in non-terminals HOT 1
- Reformatting a URL resulting in `(link)` not moving HOT 4
- Render diagnostics without exiting? HOT 5
- Length is inclusive?! HOT 1
- [Feature Request] Support highlight by tree-sitter.
- Feature Request: Make miette! macro handle related errors HOT 3
- Feature request/thoughts: Report<E> with known “base type” HOT 2
- Cannot build with only `fancy-base`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miette.