zesterer / ariadne

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

Initiial source ID and location #3

Open eaglgenes101 opened 2 years ago

eaglgenes101 commented 2 years ago

In the method to create a report builder, there are two arguments corresponding to a source ID and a location. From reading the source code, these correspond to a location field inside the report builder struct, which is only ever used in https://github.com/zesterer/ariadne/blob/e3cb394cb56ecda116a0a1caecd385a49e7f6662/src/write.rs#L137 and following lines for determining a source location in certain cases. Am I missing something, or am I correct in thinking that this initial location could (and for ease of end usage, should) be made optional?

bestouff commented 2 years ago

Also the docs aren't clear about what's its use, and the multifiles example makes it look like it's redundant.

zesterer commented 2 years ago

I think I'm going to remove this in favour of a 'blessed' primary label that gets used as the canonical error location. I do want to keep this notion of there being a canonical single location for the error though, because this would allow for reporting short form errors in a manner similar to Rust's --message-format=short.

bestouff commented 2 years ago

That sounds perfect. For now my code scans the different labels and finds the Primary one, then uses this as the location for Report::build().