dtolnay/anyhow

Customize output format

fritzrehde opened this issue · 1 comments

Is there a way to customize the output format of anyhow errors that are printed to stdout? For example, this is how it formatted by default:

Error: Failed to read instrs from ./path/to/instrs.json

Caused by:
    No such file or directory (os error 2)

Could I somehow change this formatting to

My custom error prefix: Failed to read instrs from ./path/to/instrs.json
Caused by: No such file or directory (os error 2)

or similar?

There is an example of custom formatting near the bottom of https://docs.rs/anyhow/1.0.69/anyhow/struct.Error.html#display-representations.