zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.61k stars 72 forks source link

Support backtrace #78

Open oovm opened 1 year ago

zesterer commented 1 year ago

Hi, thanks for the PR!

I think some aspects of this PR are a bit too specific for ariadne. Ariadne is intended to be a diagnostic renderer (i.e: something that takes error message text, spans, and source and converts it to human-readable output) with a specific bias toward compiler output.

For example, CausedByFrame::io_error concerns me because it's very prescriptive about how an IO error should be turned into text: this feels like it's better suited to a more Rust-oriented crate like anyhow (and kin) or some glue code between the two (an example of such a thing that I briefly worked on is here).

Additionally, the use of line/column in CausedByFrame is another point of concern for me: ariadne is intended to ingest spans from the original source, not to leave converting between byte spans and line/column and such to the end user.

I worry that a lot of this backtrace logic doesn't fit well within the existing crate scope, especially as it seems like it can't interact with label rendering (you can't, say, point to the location of a backtrace segment in the original source).

My instinct would be that this is better suited to an extension crate on top of ariadne, although it's true that there are systems that first need work in ariadne to facilitate that. What do you think?

oovm commented 1 year ago

Report as io error is indeed an abuse.

The main use should be to output the location of the call site, what information to give is up to the user.

As for whether the interaction depends on the terminal used by the user and the target platform, I really don't know any mechanism that can interact in all the default mid-range.

In fact there is a problem on my terminal, one part can be clicked, the other part can't.

QQ截图20230602204739