zesterer / ariadne

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

Add a way to get back the `location` from Report #18

Open ccgauche opened 2 years ago

ccgauche commented 2 years ago

This is quite important since in most cases we don't know at the top of our project from which file originated the error and we don't want to pass all the files imported. So we definitely need a way to get back the location so we can give the correct file while printing.

if let Err(e) = my_result {
        e.eprint(&std::fs::read_to_string(&e.location().0).unwrap());
}
zesterer commented 2 years ago

Apologies about not addressing this earlier.

Reports can require accessing multiple files, so the best approach would probably be to write a custom implementation of Cache.