1 #![deny(missing_docs, missing_debug_implementations, nonstandard_style)]
2 #![warn(unreachable_pub, rust_2018_idioms)]
3 //! You run miette? You run her code like the software? Oh. Oh! Error code for
4 //! coder! Error code for One Thousand Lines!
5 //!
6 //! ## About
7 //!
8 //! `miette` is a diagnostic library for Rust. It includes a series of
9 //! traits/protocols that allow you to hook into its error reporting facilities,
10 //! and even write your own error reports! It lets you define error types that
11 //! can print out like this (or in any format you like!):
12 //!
13 //! <img src="https://raw.githubusercontent.com/zkat/miette/main/images/serde_json.png" alt="Hi! miette also includes a screen-reader-oriented diagnostic printer that's enabled in various situations, such as when you use NO_COLOR or CLICOLOR settings, or on CI. This behavior is also fully configurable and customizable. For example, this is what this particular diagnostic will look like when the narrated printer is enabled:
14 //! \
15 //! Error: Received some bad JSON from the source. Unable to parse.
16 //!     Caused by: missing field `foo` at line 1 column 1700
17 //! \
18 //! Begin snippet for https://api.nuget.org/v3/registration5-gz-semver2/json.net/index.json starting
19 //! at line 1, column 1659
20 //! \
21 //! snippet line 1: gs&quot;:[&quot;json&quot;],&quot;title&quot;:&quot;&quot;,&quot;version&quot;:&quot;1.0.0&quot;},&quot;packageContent&quot;:&quot;https://api.nuget.o
22 //!     highlight starting at line 1, column 1699: last parsing location
23 //! \
24 //! diagnostic help: This is a bug. It might be in ruget, or it might be in the
25 //! source you're using, but it's definitely a bug and should be reported.
26 //! diagnostic error code: ruget::api::bad_json
27 //! " />
28 //!
29 //! > **NOTE: You must enable the `"fancy"` crate feature to get fancy report
30 //! output like in the screenshots above.** You should only do this in your
31 //! toplevel crate, as the fancy feature pulls in a number of dependencies that
32 //! libraries and such might not want.
33 //!
34 //! ## Table of Contents <!-- omit in toc -->
35 //!
36 //! - [About](#about)
37 //! - [Features](#features)
38 //! - [Installing](#installing)
39 //! - [Example](#example)
40 //! - [Using](#using)
41 //!   - [... in libraries](#-in-libraries)
42 //!   - [... in application code](#-in-application-code)
43 //!   - [... in `main()`](#-in-main)
44 //!   - [... diagnostic code URLs](#-diagnostic-code-urls)
45 //!   - [... snippets](#-snippets)
46 //!   - [... multiple related errors](#-multiple-related-errors)
47 //!   - [... delayed source code](#-delayed-source-code)
48 //!   - [... handler options](#-handler-options)
49 //!   - [... dynamic diagnostics](#-dynamic-diagnostics)
50 //! - [Acknowledgements](#acknowledgements)
51 //! - [License](#license)
52 //!
53 //! ## Features
54 //!
55 //! - Generic [`Diagnostic`] protocol, compatible (and dependent on)
56 //!   [`std::error::Error`].
57 //! - Unique error codes on every [`Diagnostic`].
58 //! - Custom links to get more details on error codes.
59 //! - Super handy derive macro for defining diagnostic metadata.
60 //! - Replacements for [`anyhow`](https://docs.rs/anyhow)/[`eyre`](https://docs.rs/eyre)
61 //!   types [`Result`], [`Report`] and the [`miette!`] macro for the
62 //!   `anyhow!`/`eyre!` macros.
63 //! - Generic support for arbitrary [`SourceCode`]s for snippet data, with
64 //!   default support for `String`s included.
65 //!
66 //! The `miette` crate also comes bundled with a default [`ReportHandler`] with
67 //! the following features:
68 //!
69 //! - Fancy graphical [diagnostic output](#about), using ANSI/Unicode text
70 //! - single- and multi-line highlighting support
71 //! - Screen reader/braille support, gated on [`NO_COLOR`](http://no-color.org/),
72 //!   and other heuristics.
73 //! - Fully customizable graphical theming (or overriding the printers
74 //!   entirely).
75 //! - Cause chain printing
76 //! - Turns diagnostic codes into links in [supported terminals](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
77 //!
78 //! ## Installing
79 //!
80 //! ```sh
81 //! $ cargo add miette
82 //! ```
83 //!
84 //! If you want to use the fancy printer in all these screenshots:
85 //!
86 //! ```sh
87 //! $ cargo add miette --features fancy
88 //! ```
89 //!
90 //! ## Example
91 //!
92 //! ```rust
93 //! /*
94 //! You can derive a `Diagnostic` from any `std::error::Error` type.
95 //!
96 //! `thiserror` is a great way to define them, and plays nicely with `miette`!
97 //! */
98 //! use miette::{Diagnostic, SourceSpan};
99 //! use thiserror::Error;
100 //!
101 //! #[derive(Error, Debug, Diagnostic)]
102 //! #[error("oops!")]
103 //! #[diagnostic(
104 //!     code(oops::my::bad),
105 //!     url(docsrs),
106 //!     help("try doing it better next time?")
107 //! )]
108 //! struct MyBad {
109 //!     // The Source that we're gonna be printing snippets out of.
110 //!     // This can be a String if you don't have or care about file names.
111 //!     #[source_code]
112 //!     src: NamedSource,
113 //!     // Snippets and highlights can be included in the diagnostic!
114 //!     #[label("This bit here")]
115 //!     bad_bit: SourceSpan,
116 //! }
117 //!
118 //! /*
119 //! Now let's define a function!
120 //!
121 //! Use this `Result` type (or its expanded version) as the return type
122 //! throughout your app (but NOT your libraries! Those should always return
123 //! concrete types!).
124 //! */
125 //! use miette::{NamedSource, Result};
126 //! fn this_fails() -> Result<()> {
127 //!     // You can use plain strings as a `Source`, or anything that implements
128 //!     // the one-method `Source` trait.
129 //!     let src = "source\n  text\n    here".to_string();
130 //!     let len = src.len();
131 //!
132 //!     Err(MyBad {
133 //!         src: NamedSource::new("bad_file.rs", src),
134 //!         bad_bit: (9, 4).into(),
135 //!     })?;
136 //!
137 //!     Ok(())
138 //! }
139 //!
140 //! /*
141 //! Now to get everything printed nicely, just return a `Result<()>`
142 //! and you're all set!
143 //!
144 //! Note: You can swap out the default reporter for a custom one using
145 //! `miette::set_hook()`
146 //! */
147 //! fn pretend_this_is_main() -> Result<()> {
148 //!     // kaboom~
149 //!     this_fails()?;
150 //!
151 //!     Ok(())
152 //! }
153 //! ```
154 //!
155 //! And this is the output you'll get if you run this program:
156 //!
157 //! <img src="https://raw.githubusercontent.com/zkat/miette/main/images/single-line-example.png" alt="
158 //! Narratable printout:
159 //! \
160 //! Error: Types mismatched for operation.
161 //!     Diagnostic severity: error
162 //! Begin snippet starting at line 1, column 1
163 //! \
164 //! snippet line 1: 3 + &quot;5&quot;
165 //!     label starting at line 1, column 1: int
166 //!     label starting at line 1, column 1: doesn't support these values.
167 //!     label starting at line 1, column 1: string
168 //! diagnostic help: Change int or string to be the right types and try again.
169 //! diagnostic code: nu::parser::unsupported_operation
170 //! For more details, see https://docs.rs/nu-parser/0.1.0/nu-parser/enum.ParseError.html#variant.UnsupportedOperation">
171 //!
172 //! ## Using
173 //!
174 //! ### ... in libraries
175 //!
176 //! `miette` is _fully compatible_ with library usage. Consumers who don't know
177 //! about, or don't want, `miette` features can safely use its error types as
178 //! regular [`std::error::Error`].
179 //!
180 //! We highly recommend using something like [`thiserror`](https://docs.rs/thiserror)
181 //! to define unique error types and error wrappers for your library.
182 //!
183 //! While `miette` integrates smoothly with `thiserror`, it is _not required_.
184 //! If you don't want to use the [`Diagnostic`] derive macro, you can implement
185 //! the trait directly, just like with `std::error::Error`.
186 //!
187 //! ```rust
188 //! // lib/error.rs
189 //! use miette::{Diagnostic, SourceSpan};
190 //! use thiserror::Error;
191 //!
192 //! #[derive(Error, Diagnostic, Debug)]
193 //! pub enum MyLibError {
194 //!     #[error(transparent)]
195 //!     #[diagnostic(code(my_lib::io_error))]
196 //!     IoError(#[from] std::io::Error),
197 //!
198 //!     #[error("Oops it blew up")]
199 //!     #[diagnostic(code(my_lib::bad_code))]
200 //!     BadThingHappened,
201 //!
202 //!     #[error(transparent)]
203 //!     // Use `#[diagnostic(transparent)]` to wrap another [`Diagnostic`]. You won't see labels otherwise
204 //!     #[diagnostic(transparent)]
205 //!     AnotherError(#[from] AnotherError),
206 //! }
207 //!
208 //! #[derive(Error, Diagnostic, Debug)]
209 //! #[error("another error")]
210 //! pub struct AnotherError {
211 //!    #[label("here")]
212 //!    pub at: SourceSpan
213 //! }
214 //! ```
215 //!
216 //! Then, return this error type from all your fallible public APIs. It's a best
217 //! practice to wrap any "external" error types in your error `enum` instead of
218 //! using something like [`Report`] in a library.
219 //!
220 //! ### ... in application code
221 //!
222 //! Application code tends to work a little differently than libraries. You
223 //! don't always need or care to define dedicated error wrappers for errors
224 //! coming from external libraries and tools.
225 //!
226 //! For this situation, `miette` includes two tools: [`Report`] and
227 //! [`IntoDiagnostic`]. They work in tandem to make it easy to convert regular
228 //! `std::error::Error`s into [`Diagnostic`]s. Additionally, there's a
229 //! [`Result`] type alias that you can use to be more terse.
230 //!
231 //! When dealing with non-`Diagnostic` types, you'll want to
232 //! `.into_diagnostic()` them:
233 //!
234 //! ```rust
235 //! // my_app/lib/my_internal_file.rs
236 //! use miette::{IntoDiagnostic, Result};
237 //! use semver::Version;
238 //!
239 //! pub fn some_tool() -> Result<Version> {
240 //!     Ok("1.2.x".parse().into_diagnostic()?)
241 //! }
242 //! ```
243 //!
244 //! `miette` also includes an `anyhow`/`eyre`-style `Context`/`WrapErr` traits
245 //! that you can import to add ad-hoc context messages to your `Diagnostic`s, as
246 //! well, though you'll still need to use `.into_diagnostic()` to make use of
247 //! it:
248 //!
249 //! ```rust
250 //! // my_app/lib/my_internal_file.rs
251 //! use miette::{IntoDiagnostic, Result, WrapErr};
252 //! use semver::Version;
253 //!
254 //! pub fn some_tool() -> Result<Version> {
255 //!     Ok("1.2.x"
256 //!         .parse()
257 //!         .into_diagnostic()
258 //!         .wrap_err("Parsing this tool's semver version failed.")?)
259 //! }
260 //! ```
261 //!
262 //! To construct your own simple adhoc error use the [miette!] macro:
263 //! ```rust
264 //! // my_app/lib/my_internal_file.rs
265 //! use miette::{miette, IntoDiagnostic, Result, WrapErr};
266 //! use semver::Version;
267 //!
268 //! pub fn some_tool() -> Result<Version> {
269 //!     let version = "1.2.x";
270 //!     Ok(version
271 //!         .parse()
272 //!         .map_err(|_| miette!("Invalid version {}", version))?)
273 //! }
274 //! ```
275 //! There are also similar [bail!] and [ensure!] macros.
276 //!
277 //! ### ... in `main()`
278 //!
279 //! `main()` is just like any other part of your application-internal code. Use
280 //! `Result` as your return value, and it will pretty-print your diagnostics
281 //! automatically.
282 //!
283 //! > **NOTE:** You must enable the `"fancy"` crate feature to get fancy report
284 //! output like in the screenshots here.** You should only do this in your
285 //! toplevel crate, as the fancy feature pulls in a number of dependencies that
286 //! libraries and such might not want.
287 //!
288 //! ```rust
289 //! use miette::{IntoDiagnostic, Result};
290 //! use semver::Version;
291 //!
292 //! fn pretend_this_is_main() -> Result<()> {
293 //!     let version: Version = "1.2.x".parse().into_diagnostic()?;
294 //!     println!("{}", version);
295 //!     Ok(())
296 //! }
297 //! ```
298 //!
299 //! Please note: in order to get fancy diagnostic rendering with all the pretty
300 //! colors and arrows, you should install `miette` with the `fancy` feature
301 //! enabled:
302 //!
303 //! ```toml
304 //! miette = { version = "X.Y.Z", features = ["fancy"] }
305 //! ```
306 //!
307 //! ### ... diagnostic code URLs
308 //!
309 //! `miette` supports providing a URL for individual diagnostics. This URL will
310 //! be displayed as an actual link in supported terminals, like so:
311 //!
312 //! <img
313 //! src="https://raw.githubusercontent.com/zkat/miette/main/images/code_linking.png"
314 //! alt=" Example showing the graphical report printer for miette
315 //! pretty-printing an error code. The code is underlined and followed by text
316 //! saying to 'click here'. A hover tooltip shows a full-fledged URL that can be
317 //! Ctrl+Clicked to open in a browser.
318 //! \
319 //! This feature is also available in the narratable printer. It will add a line
320 //! after printing the error code showing a plain URL that you can visit.
321 //! ">
322 //!
323 //! To use this, you can add a `url()` sub-param to your `#[diagnostic]`
324 //! attribute:
325 //!
326 //! ```rust
327 //! use miette::Diagnostic;
328 //! use thiserror::Error;
329 //!
330 //! #[derive(Error, Diagnostic, Debug)]
331 //! #[error("kaboom")]
332 //! #[diagnostic(
333 //!     code(my_app::my_error),
334 //!     // You can do formatting!
335 //!     url("https://my_website.com/error_codes#{}", self.code().unwrap())
336 //! )]
337 //! struct MyErr;
338 //! ```
339 //!
340 //! Additionally, if you're developing a library and your error type is exported
341 //! from your crate's top level, you can use a special `url(docsrs)` option
342 //! instead of manually constructing the URL. This will automatically create a
343 //! link to this diagnostic on `docs.rs`, so folks can just go straight to your
344 //! (very high quality and detailed!) documentation on this diagnostic:
345 //!
346 //! ```rust
347 //! use miette::Diagnostic;
348 //! use thiserror::Error;
349 //!
350 //! #[derive(Error, Diagnostic, Debug)]
351 //! #[diagnostic(
352 //!     code(my_app::my_error),
353 //!     // Will link users to https://docs.rs/my_crate/0.0.0/my_crate/struct.MyErr.html
354 //!     url(docsrs)
355 //! )]
356 //! #[error("kaboom")]
357 //! struct MyErr;
358 //! ```
359 //!
360 //! ### ... snippets
361 //!
362 //! Along with its general error handling and reporting features, `miette` also
363 //! includes facilities for adding error spans/annotations/labels to your
364 //! output. This can be very useful when an error is syntax-related, but you can
365 //! even use it to print out sections of your own source code!
366 //!
367 //! To achieve this, `miette` defines its own lightweight [`SourceSpan`] type.
368 //! This is a basic byte-offset and length into an associated [`SourceCode`]
369 //! and, along with the latter, gives `miette` all the information it needs to
370 //! pretty-print some snippets! You can also use your own `Into<SourceSpan>`
371 //! types as label spans.
372 //!
373 //! The easiest way to define errors like this is to use the
374 //! `derive(Diagnostic)` macro:
375 //!
376 //! ```rust
377 //! use miette::{Diagnostic, SourceSpan};
378 //! use thiserror::Error;
379 //!
380 //! #[derive(Diagnostic, Debug, Error)]
381 //! #[error("oops")]
382 //! #[diagnostic(code(my_lib::random_error))]
383 //! pub struct MyErrorType {
384 //!     // The `Source` that miette will use.
385 //!     #[source_code]
386 //!     src: String,
387 //!
388 //!     // This will underline/mark the specific code inside the larger
389 //!     // snippet context.
390 //!     #[label = "This is the highlight"]
391 //!     err_span: SourceSpan,
392 //!
393 //!     // You can add as many labels as you want.
394 //!     // They'll be rendered sequentially.
395 //!     #[label("This is bad")]
396 //!     snip2: (usize, usize), // `(usize, usize)` is `Into<SourceSpan>`!
397 //!
398 //!     // Snippets can be optional, by using Option:
399 //!     #[label("some text")]
400 //!     snip3: Option<SourceSpan>,
401 //!
402 //!     // with or without label text
403 //!     #[label]
404 //!     snip4: Option<SourceSpan>,
405 //! }
406 //! ```
407 //!
408 //! #### ... help text
409 //! `miette` provides two facilities for supplying help text for your errors:
410 //!
411 //! The first is the `#[help()]` format attribute that applies to structs or
412 //! enum variants:
413 //!
414 //! ```rust
415 //! use miette::Diagnostic;
416 //! use thiserror::Error;
417 //!
418 //! #[derive(Debug, Diagnostic, Error)]
419 //! #[error("welp")]
420 //! #[diagnostic(help("try doing this instead"))]
421 //! struct Foo;
422 //! ```
423 //!
424 //! The other is by programmatically supplying the help text as a field to
425 //! your diagnostic:
426 //!
427 //! ```rust
428 //! use miette::Diagnostic;
429 //! use thiserror::Error;
430 //!
431 //! #[derive(Debug, Diagnostic, Error)]
432 //! #[error("welp")]
433 //! #[diagnostic()]
434 //! struct Foo {
435 //!     #[help]
436 //!     advice: Option<String>, // Can also just be `String`
437 //! }
438 //!
439 //! let err = Foo {
440 //!     advice: Some("try doing this instead".to_string()),
441 //! };
442 //! ```
443 //!
444 //! ### ... multiple related errors
445 //!
446 //! `miette` supports collecting multiple errors into a single diagnostic, and
447 //! printing them all together nicely.
448 //!
449 //! To do so, use the `#[related]` tag on any `IntoIter` field in your
450 //! `Diagnostic` type:
451 //!
452 //! ```rust
453 //! use miette::Diagnostic;
454 //! use thiserror::Error;
455 //!
456 //! #[derive(Debug, Error, Diagnostic)]
457 //! #[error("oops")]
458 //! struct MyError {
459 //!     #[related]
460 //!     others: Vec<MyError>,
461 //! }
462 //! ```
463 //!
464 //! ### ... delayed source code
465 //!
466 //! Sometimes it makes sense to add source code to the error message later.
467 //! One option is to use [`with_source_code()`](Report::with_source_code)
468 //! method for that:
469 //!
470 //! ```rust,no_run
471 //! use miette::{Diagnostic, SourceSpan};
472 //! use thiserror::Error;
473 //!
474 //! #[derive(Diagnostic, Debug, Error)]
475 //! #[error("oops")]
476 //! #[diagnostic()]
477 //! pub struct MyErrorType {
478 //!     // Note: label but no source code
479 //!     #[label]
480 //!     err_span: SourceSpan,
481 //! }
482 //!
483 //! fn do_something() -> miette::Result<()> {
484 //!     // This function emits actual error with label
485 //!     return Err(MyErrorType {
486 //!         err_span: (7..11).into(),
487 //!     })?;
488 //! }
489 //!
490 //! fn main() -> miette::Result<()> {
491 //!     do_something().map_err(|error| {
492 //!         // And this code provides the source code for inner error
493 //!         error.with_source_code(String::from("source code"))
494 //!     })
495 //! }
496 //! ```
497 //!
498 //! Also source code can be provided by a wrapper type. This is especially
499 //! useful in combination with `related`, when multiple errors should be
500 //! emitted at the same time:
501 //!
502 //! ```rust,no_run
503 //! use miette::{Diagnostic, Report, SourceSpan};
504 //! use thiserror::Error;
505 //!
506 //! #[derive(Diagnostic, Debug, Error)]
507 //! #[error("oops")]
508 //! #[diagnostic()]
509 //! pub struct InnerError {
510 //!     // Note: label but no source code
511 //!     #[label]
512 //!     err_span: SourceSpan,
513 //! }
514 //!
515 //! #[derive(Diagnostic, Debug, Error)]
516 //! #[error("oops: multiple errors")]
517 //! #[diagnostic()]
518 //! pub struct MultiError {
519 //!     // Note source code by no labels
520 //!     #[source_code]
521 //!     source_code: String,
522 //!     // The source code above is used for these errors
523 //!     #[related]
524 //!     related: Vec<InnerError>,
525 //! }
526 //!
527 //! fn do_something() -> Result<(), Vec<InnerError>> {
528 //!     Err(vec![
529 //!         InnerError {
530 //!             err_span: (0..6).into(),
531 //!         },
532 //!         InnerError {
533 //!             err_span: (7..11).into(),
534 //!         },
535 //!     ])
536 //! }
537 //!
538 //! fn main() -> miette::Result<()> {
539 //!     do_something().map_err(|err_list| MultiError {
540 //!         source_code: "source code".into(),
541 //!         related: err_list,
542 //!     })?;
543 //!     Ok(())
544 //! }
545 //! ```
546 //!
547 //! ### ... Diagnostic-based error sources.
548 //!
549 //! When one uses the `#[source]` attribute on a field, that usually comes
550 //! from `thiserror`, and implements a method for
551 //! [`std::error::Error::source`]. This works in many cases, but it's lossy:
552 //! if the source of the diagnostic is a diagnostic itself, the source will
553 //! simply be treated as an `std::error::Error`.
554 //!
555 //! While this has no effect on the existing _reporters_, since they don't use
556 //! that information right now, APIs who might want this information will have
557 //! no access to it.
558 //!
559 //! If it's important for you for this information to be available to users,
560 //! you can use `#[diagnostic_source]` alongside `#[source]`. Not that you
561 //! will likely want to use _both_:
562 //!
563 //! ```rust
564 //! use miette::Diagnostic;
565 //! use thiserror::Error;
566 //!
567 //! #[derive(Debug, Diagnostic, Error)]
568 //! #[error("MyError")]
569 //! struct MyError {
570 //!     #[source]
571 //!     #[diagnostic_source]
572 //!     the_cause: OtherError,
573 //! }
574 //!
575 //! #[derive(Debug, Diagnostic, Error)]
576 //! #[error("OtherError")]
577 //! struct OtherError;
578 //! ```
579 //!
580 //! ### ... handler options
581 //!
582 //! [`MietteHandler`] is the default handler, and is very customizable. In
583 //! most cases, you can simply use [`MietteHandlerOpts`] to tweak its behavior
584 //! instead of falling back to your own custom handler.
585 //!
586 //! Usage is like so:
587 //!
588 //! ```rust,ignore
589 //! miette::set_hook(Box::new(|_| {
590 //!     Box::new(
591 //!         miette::MietteHandlerOpts::new()
592 //!             .terminal_links(true)
593 //!             .unicode(false)
594 //!             .context_lines(3)
595 //!             .tab_width(4)
596 //!             .build(),
597 //!     )
598 //! }))
599 //!
600 //! # .unwrap()
601 //! ```
602 //!
603 //! See the docs for [`MietteHandlerOpts`] for more details on what you can
604 //! customize!
605 //!
606 //! ### ... dynamic diagnostics
607 //!
608 //! If you...
609 //! - ...don't know all the possible errors upfront
610 //! - ...need to serialize/deserialize errors
611 //! then you may want to use [`miette!`], [`diagnostic!`] macros or
612 //! [`MietteDiagnostic`] directly to create diagnostic on the fly.
613 //!
614 //! ```rust,ignore
615 //! # use miette::{miette, LabeledSpan, Report};
616 //!
617 //! let source = "2 + 2 * 2 = 8".to_string();
618 //! let report = miette!(
619 //!   labels = vec[
620 //!       LabeledSpan::at(12..13, "this should be 6"),
621 //!   ],
622 //!   help = "'*' has greater precedence than '+'",
623 //!   "Wrong answer"
624 //! ).with_source_code(source);
625 //! println!("{:?}", report)
626 //! ```
627 //!
628 //! ## Acknowledgements
629 //!
630 //! `miette` was not developed in a void. It owes enormous credit to various
631 //! other projects and their authors:
632 //!
633 //! - [`anyhow`](http://crates.io/crates/anyhow) and [`color-eyre`](https://crates.io/crates/color-eyre):
634 //!   these two enormously influential error handling libraries have pushed
635 //!   forward the experience of application-level error handling and error
636 //!   reporting. `miette`'s `Report` type is an attempt at a very very rough
637 //!   version of their `Report` types.
638 //! - [`thiserror`](https://crates.io/crates/thiserror) for setting the standard
639 //!   for library-level error definitions, and for being the inspiration behind
640 //!   `miette`'s derive macro.
641 //! - `rustc` and [@estebank](https://github.com/estebank) for their
642 //!   state-of-the-art work in compiler diagnostics.
643 //! - [`ariadne`](https://crates.io/crates/ariadne) for pushing forward how
644 //!   _pretty_ these diagnostics can really look!
645 //!
646 //! ## License
647 //!
648 //! `miette` is released to the Rust community under the [Apache license
649 //! 2.0](./LICENSE).
650 //!
651 //! It also includes code taken from [`eyre`](https://github.com/yaahc/eyre),
652 //! and some from [`thiserror`](https://github.com/dtolnay/thiserror), also
653 //! under the Apache License. Some code is taken from
654 //! [`ariadne`](https://github.com/zesterer/ariadne), which is MIT licensed.
655 pub use miette_derive::*;
656 
657 pub use error::*;
658 pub use eyreish::*;
659 #[cfg(feature = "fancy-no-backtrace")]
660 pub use handler::*;
661 pub use handlers::*;
662 pub use miette_diagnostic::*;
663 pub use named_source::*;
664 #[cfg(feature = "fancy")]
665 pub use panic::*;
666 pub use protocol::*;
667 
668 mod chain;
669 mod diagnostic_chain;
670 mod error;
671 mod eyreish;
672 #[cfg(feature = "fancy-no-backtrace")]
673 mod handler;
674 mod handlers;
675 #[doc(hidden)]
676 pub mod macro_helpers;
677 mod miette_diagnostic;
678 mod named_source;
679 #[cfg(feature = "fancy")]
680 mod panic;
681 mod protocol;
682 mod source_impls;
683