Commit Graph

166 Commits

Author SHA1 Message Date
Kat Marchán b0453215f6
feat(panic): improved backtrace handling
Fixes: https://github.com/zkat/miette/issues/92
2023-03-31 17:08:20 -07:00
Aria Beingessner 0b445dc2b4
fix(tests): disable doctest that doesn't work with default feature flags (#248) 2023-03-30 09:19:51 -07:00
Aria Beingessner 159f2b354b
fix(colors): change unicode to default to ansi (#249) 2023-03-30 09:18:52 -07:00
Yoni Feng 566d6be6e3
misc(perf): nit perf improvements (#244) 2023-03-29 20:21:40 -07:00
George Pollard 443d240f49
fix(atty): Switch out `atty` for `is-terminal` (#229) 2023-03-13 21:10:21 -07:00
Erich Gubler ed486c959d
feat(protocol): implement `Ord` for `Severity` (#240)
Fixes: https://github.com/zkat/miette/issues/239
2023-03-01 15:48:11 -08:00
dalance 3497508aa9
fix(graphical): Fix wrong severity of related errors (#234) 2023-02-08 16:26:27 -08:00
Lucas Kent ebc61b5cf8
docs: Mention miette::miette! macro under "... in application code" (#233) 2023-01-30 10:21:50 -08:00
Benjamin Lee 8b56d277ef
fix(graphical): Fix panic with span extending past end of line (#221)
Fixes: #215 

This also changes the behavior with spans including a CRLF line-ending.
Before the panic bug was introduced, these were rendered with the CRLF
being two visual columns wide. Now, any span extending past the EOL is
treated as including one extra visual column.
2022-11-23 16:35:13 -08:00
Sean Lynch c857595e1a
feat(SourceCode): Implement SourceCode for Vec<u8> (#216) 2022-11-06 17:42:33 -08:00
Benjamin Lee b8810ee3d8
fix(graphical): Fix panic with zero-width span at end of line (#204)
This was introduced in 196c09ce7a, and is
a simple off-by-one error.
2022-10-28 16:20:10 -07:00
Rain ec7df952eb tests: add tests to ensure that boxed reports forward all methods
In previous commits we found that boxed reports weren't forwarding every
method. Add a test to ensure that they do.
2022-10-24 19:04:51 -07:00
Rain 1a27033d7a feat(error): impl AsRef<dyn StdError> for Report
This seems like an easy implementation to fill out, and will be used for
tests in the following commit.
2022-10-24 19:04:51 -07:00
Rain 3fc5c04cbb fix(wrapper): complete forwarding Diagnostic implementations
They were missing `diagnostic_source()` which was recently added.
2022-10-24 19:04:51 -07:00
Rain 0660d2f43c feat(report): `Report::new_boxed`
This is already currently accessible with `miette!`, but I missed that
because it isn't clearly documented. Add a constructor to mirror
`Report::new` and `Report::msg`.
2022-10-24 19:04:51 -07:00
Benjamin Lee 196c09ce7a
fix(graphical): Align highlights correctly with wide unicode characters and tabs (#202)
Fixes: https://github.com/zkat/miette/issues/97
Fixes: https://github.com/zkat/miette/issues/87

Tabs are always expanded to spaces by the graphical handler, and `tab_width` now defaults to 4. Instead of replacing every tab with a fixed number of spaces, spaces are used to align to the next tabstop. `tab_width` controls the space between tabstops rather than the fixed width of each tab character.

Co-authored-by: Benjamin Lee <benjamin@computer.surgery>
2022-09-10 14:20:37 -07:00
Nathan Whitaker 5f3429b062
fix(miri): Resolve Miri's concerns around unsafe code (#197) 2022-08-25 08:30:18 -07:00
Pig Fang 12279f83a8
docs: remove sentence about `cargo-edit` (#198) 2022-08-21 08:33:51 -07:00
Luca Palmieri b9ea587159
feat(graphical): Allow miette users to opt-out of the rendering of the cause chain (#192)
Fixes: https://github.com/zkat/miette/issues/191
2022-08-09 17:32:02 -07:00
Andrew Hickman c3e6c98336
fix(utils): Fix off-by-one error in SourceOffset::from_location (#190) 2022-08-02 14:38:22 -07:00
Leon Breedt c95f58c87a
feat(json): `causes` support (#188)
Fixes: https://github.com/zkat/miette/issues/187
2022-07-31 11:47:06 -07:00
Kat Marchán e286c705fd
fix(docs): readme was getting cut off during generation
Fixes: https://github.com/zkat/miette/issues/174
2022-07-24 10:24:07 -07:00
Rain 12dc40070a
fix(graphical): handle an empty source (#183)
In some cases the source can be completely empty -- handle that in a reasonable fashion.
2022-07-08 19:41:12 -07:00
Andrew Hickman 85da6a8407
feat(protocol): Implement SourceCode for Arc<str> (and similar types) (#181) 2022-06-25 10:58:56 -07:00
Benjamin Lee 1816b06a2e
feat(theme): restructure automatic color selection (#177)
Fixes: https://github.com/zkat/miette/issues/176

Change the default ansi color theme to use colors that are more similar
to the colors from the default RGB theme. In particular, don't use red
for any of the span labels, since that color is also used for errors.

BREAKING CHANGES:
* the default theme now prefers ANSI colors, even if RGB is supported
* `MietteHandlerOpts::ansi_colors` is removed
* `MietteHandlerOpts::rgb_color` now takes an enum that controls the
  color format used when color support is enabled, and has no effect
  otherwise.
2022-06-24 08:30:36 -07:00
Aria Beingessner b193d3c002
fix(json): Don't escape single-quotes, that's not valid json (#180) 2022-06-24 08:28:01 -07:00
Kat Marchán 0a4cf4ad24
fix(tests): add Display impl to diagnostic_source example 2022-05-05 12:44:49 -07:00
Kat Marchán a03bfe2e1b
docs: document new diagnostic_source feature 2022-05-05 08:56:27 -07:00
Matthias Beyer bc449c8426
feat(diagnostic_source): add protocol method for Diagnostic-aware source chaining (#165)
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-05-05 08:32:37 -07:00
Matthias Beyer 33c8903313
fix: cargo fmt (#168)
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-05-05 08:30:13 -07:00
Marcel Müller 2451ad6a96
docs(IntoDiagnostic): Warn of potential data loss (#161)
Fixes: https://github.com/zkat/miette/issues/160

This patch expands on the effects of using IntoDiagnostic and warns
users of potential loss of information when using it on `Diagnostic`
types.
2022-04-23 11:35:39 -07:00
Kat Marchán 1a36fa7ec8
fix(graphical): fix issue with duplicate labels when span len is 0 (#159)
Fixes: https://github.com/zkat/miette/issues/130
2022-04-22 19:31:51 -07:00
Kat Marchán 084ed138b7
feat(related): print related prefixes according to severity (#158)
Fixes: https://github.com/zkat/miette/issues/139
2022-04-22 18:55:45 -07:00
Kat Marchán 1e1d615253 feat(spans): add From shorthand for zero-length SourceSpans 2022-04-22 18:44:09 -07:00
Kat Marchán 9da62cd05d feat(label): use macro magic instead of optional flag for optional labels 2022-04-17 22:43:01 -07:00
Kat Marchán ea55f458fa feat(help): allow non-option values in #[help] fields 2022-04-17 22:43:01 -07:00
Kat Marchán 23ee3642d1
feat(labels): allow optional labels in derive macro (#153)
Fixes: https://github.com/zkat/miette/issues/110
2022-04-17 19:41:10 -07:00
Kat Marchán 45093c2f58
feat(help): update macro to allow optional help text (#152)
Fixes: https://github.com/zkat/miette/issues/148
2022-04-17 18:19:28 -07:00
Rain 5e54b29acf
feat(spans): make SourceSpan implement Copy (#151)
SourceSpan is just a pair of usizes, so it's cheap to copy.
2022-04-17 15:27:11 -07:00
Rain 97197601ee
fix(theme): set correct field in MietteHandlerOpts::ansi_colors (#150) 2022-04-13 17:21:22 -07:00
Kat Marchán 37cda4a3a4
fix(fmt): cargo fmt 2022-04-03 20:31:18 -07:00
Kat Marchán b98b098282
fix(clippy): misc clippy fixes 2022-04-03 18:33:51 -07:00
Finomnis b4a9d4cd9b
feat(report): Add conversion from Report to Box<dyn Error> (#149) 2022-04-03 13:10:32 -07:00
Bartek Iwańczuk 5151411ebb
feat: add fancy-no-backtrace feature (#144) 2022-03-22 12:30:52 -07:00
Christopher Durham 70e84f9a01
fix(handler): Apply MietteHandlerOpts::graphical_theme (#138)
Fixes: https://github.com/zkat/miette/issues/134
2022-03-18 16:30:00 -07:00
Christopher Durham b6a6cc9e75
feat(reporter): Allow GraphicalReportHandler to disable url display (#137) 2022-03-18 16:28:54 -07:00
Christopher Durham 209275d437
fix(colors): handler_opts.color(false) should disable color (#133) 2022-03-17 20:35:45 -07:00
Moritz Mœller 5d23c0d61d
fix(docs): Docs overhaul (#124)
* Fixed/formatted all intradoc links. Various other small doc fixes/typography/etc.

* Clarified semantic similarity with anyhow/eyre types/macros.

* Removed unused MietteError::SetPrinterFailure.

* README now generaed from lib.rs via `cargo readme`.

* More doc fixes, made ErrorHook type public.

* Indentation (docs).
2022-02-25 08:39:18 -08:00
Paul Colomiets 50bcec909a
fix(handlers): source code propagation for JSON handler (#122)
A part of fix of #99, follow up of #117
2022-02-22 16:06:29 -08:00
Paul Colomiets 75d4505e7d
feat(derive): allow `Report` in `related` (#121)
Fixes: #119
2022-02-21 19:12:37 -08:00