Commit Graph

103 Commits

Author SHA1 Message Date
Bruce Mitchener aa07c18abd tests: Fix `cargo test` with default features.
A couple of tests require `fancy-no-backtrace`, so mark them
accordingly.
2023-09-24 09:48:15 +07:00
Will Crichton db0b7e403a
feat(labels): Add support for primary label in specifying line/col information (#291) 2023-09-20 15:36:33 -07:00
Bruce Mitchener cc81382a60
fix(misc): Improve ci and fix clippy (#290)
* ci: Update actions, replace actions-rs.

* `actions/checkout` is updated from `v1` to the current `v4`.
* `actions-rs/toolchain` is replaced by `dtolnay/rust-toolchain` as
  the `actions-rs` actions haven't been maintained in a long time.

* clippy: Remove unnecessary call to `into_iter`.

The parameter takes `IntoIterator`, so we don't have to call
`into_iter` at the call site.

* clippy: Remove explicit lifetime that can be elided.

* clippy: tests: Fix useless conversion warnings.

* clippy: tests: Remove call to `format!`.

* Fix minimal-versions build.

Due to changes in the nightly compiler, using a recent nightly
requires proc-macro2 1.0.60 or later:

https://github.com/dtolnay/proc-macro2/issues/356

* ci: Use is-terminal 0.4.7 for MSRV builds.

is-terminal 0.4.8 updated its MSRV to 1.63, so we can't use it
with our MSRV of 1.56. Force usage of the older version which has
an older MSRV.
2023-09-20 10:37:40 -07:00
Bennett Hardwick 2e3e5c9d15
feat(protocol): add StdError impl for Box<dyn Diagnostic + Send + Sync> (#273) 2023-06-28 18:58:35 -07:00
Marcel Müller aefe323780
feat(nested): Render inner diagnostics (#170) 2023-05-18 15:41:17 -07:00
Gavrilikhin Daniil 024145dbdd
Add dynamic diagnostic (#262) 2023-05-13 13:59:43 -07:00
Alexander Seiler 675f3411e3
fix(misc): Correct some typos (#255)
Signed-off-by: Alexander Seiler <seileralex@gmail.com>
2023-04-25 21:07:18 -07:00
dalance 3497508aa9
fix(graphical): Fix wrong severity of related errors (#234) 2023-02-08 16:26:27 -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
Daniel Rivas c88f0b5aa0
fix(derive): elide lifetimes in derived functions (#226) 2022-11-21 09:51:10 -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
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
Leon Breedt c95f58c87a
feat(json): `causes` support (#188)
Fixes: https://github.com/zkat/miette/issues/187
2022-07-31 11:47:06 -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
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
Marcel Müller f783a0e2ae
Allow using smartpointers with source_diagnostic (#169)
* Add more tests for diagnostic_source

* Use Borrow::borrow instead of AsRef

AsRef is not reflexive, meaning that it is not implemented as &T for all
T. Borrow is though, so we use that to make sure that we always get a
reference that is correct, even in the presence of smart pointers.
2022-05-13 08:19:05 -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
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 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
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
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
Paul Colomiets 3a17fceabb feat(handlers): propagate source code to related errors
Fixes #99
2022-02-19 16:58:48 -08:00
Paul Colomiets 50519264d4 feat(report): add `with_source_code`
Fixes #64
2022-02-19 16:58:48 -08:00
Kyle Brown 5b8b5478b6
feat(derive): Make derive macro `diagnostic` attribute more flexible. (#115)
Fixes: #114 

* Improved defaulting

* Added correct combining logic
Added variable number of diagnostic attributes

* Error handling, testing, and docs improvements

Co-authored-by: Kyle Brown <kyleb@liquidrocketry.com>
2022-02-17 22:04:03 -08:00
Paul Colomiets 2649fd27c4
feat(Report): adds `.context()` method to the `Report` (#109)
Techically there was a hidden undocumented `context` method. But it was
just copied from the `eyre` and there is no evidence that it was used by
any user in miette (the method was an alias for `.handler()`).

Fixes #108
2022-01-17 17:16:08 -08:00
Paul Colomiets f158f4e370
fix(handlers): Fix label position (#107)
Fixes #106

While fixing the bug I've also extended the handler to print not just
where label starts but also where label ends.

Also implements #97, but for narratabble handler only.

This adds dependency on `unicode-width`, but it was already in the
dependency chain (`textwidth` depends on it). Although, previously it
was only for `"fancy"` feature, now it always required since narratable
handler is supported without `"fancy"`.
2022-01-17 11:07:29 -08:00
Paul Colomiets 645ef6a1b6
fix(json): proper escapes for JSON strings (#101)
Includes two fixes:
1. Things like `\n` are not doubly-escaped any more
2. The backslash `\` itself in the source is escaped
2022-01-07 17:35:24 -08:00
Paul Colomiets 52e5ec8064
fix(chain): correct `Chain` structure exported (#102)
This fixes all current complier and clippy warnings.
2022-01-07 17:34:39 -08:00
dvermd 53b246829a
feat(handlers): Add JSON handler (#90) 2021-11-15 08:49:22 -08:00
Kirill Vasiltsov 1f70140c2e
feat(tabs): Add replace tabs with spaces option (#82)
Fixes: https://github.com/zkat/miette/issues/73
2021-10-05 21:05:57 -07:00
Kat Marchán fc917021ea tests: got narrated tests passing again 2021-09-22 16:34:21 -07:00
Kat Marchán b10693a91c tests: fix doctests and such 2021-09-22 16:34:21 -07:00
Kat Marchán eb9f6986e9 tests: all graphical tests passing 2021-09-22 16:34:21 -07:00
Kat Marchán 8e11baab7b feat(related): Add related diagnostics (#68)
Fixes: https://github.com/zkat/miette/issues/47
2021-09-22 16:34:21 -07:00
Kat Marchán 3a901ace68 tests: more testing 2021-09-22 16:34:21 -07:00
Kat Marchán 49f635fb65 tests: rename printer.rs to graphical.rs 2021-09-22 16:34:21 -07:00
Kat Marchán 0544d7654e tests: update printer tests so they compile 2021-09-22 16:34:21 -07:00
Kat Marchán f87b158b22 feat(labels): replace snippet stuff with simpler labels (#62) 2021-09-22 16:34:21 -07:00
Kat Marchán cd69a8ae92 test: prefix Error: to make things look more accurate 2021-09-22 16:34:21 -07:00
Kat Marchán 2c43740346 feat(theme): more styling changes 2021-09-22 16:34:21 -07:00
Kat Marchán 559113bd1c tests: add test for wide character support 2021-09-22 16:34:21 -07:00