Skip to main content

Crate bias_miette

Crate bias_miette 

Source
Expand description

You run miette? You run her code like the software? Oh. Oh! Error code for coder! Error code for One Thousand Lines!

§About

miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports! It lets you define error types that can print out like this (or in any format you like!):

<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:

§Acknowledgements

miette was not developed in a void. It owes enormous credit to various other projects and their authors:

  • anyhow and color-eyre: these two enormously influential error handling libraries have pushed forward the experience of application-level error handling and error reporting. miette’s Report type is an attempt at a very very rough version of their Report types.
  • thiserror for setting the standard for library-level error definitions, and for being the inspiration behind miette’s derive macro.
  • rustc and @estebank for their state-of-the-art work in compiler diagnostics.
  • ariadne for pushing forward how pretty these diagnostics can really look!

§License

miette is released to the Rust community under the Apache license 2.0.

It also includes code taken from eyre, and some from thiserror, also under the Apache License. Some code is taken from ariadne, which is MIT licensed.

Structs§

DebugReportHandler
[ReportHandler] that renders plain text and avoids extraneous graphics. It’s optimized for screen readers and braille users, but is also used in any non-graphical environments, such as non-TTY output.
GraphicalReportHandler
A [ReportHandler] that displays a given Report in a quasi-graphical way, using terminal colors, unicode drawing characters, and other such things.
GraphicalTheme
Theme used by GraphicalReportHandler to render fancy Diagnostic reports.
JSONReportHandler
[ReportHandler] that renders JSON output. It’s a machine-readable output.
LabeledSpan
A labeled SourceSpan.
MietteDiagnostic
Diagnostic that can be created at runtime.
MietteSpanContents
Basic implementation of the SpanContents trait, for convenience.
NamedSource
Utility struct for when you have a regular SourceCode type that doesn’t implement name. For example String. Or if you want to override the name returned by the SourceCode.
NarratableReportHandler
[ReportHandler] that renders plain text and avoids extraneous graphics. It’s optimized for screen readers and braille users, but is also used in any non-graphical environments, such as non-TTY output.
SourceOffset
Newtype that represents the ByteOffset from the beginning of a SourceCode
SourceSpan
Span within a SourceCode
ThemeCharacters
Characters to be used when drawing when using GraphicalReportHandler.
ThemeStyles
Styles for various parts of graphical rendering for the GraphicalReportHandler.

Enums§

MietteError
Error enum for miette. Used by certain operations in the protocol.
Severity
Diagnostic severity. Intended to be used by ReportHandlers to change the way different Diagnostics are displayed. Defaults to Severity::Error.

Traits§

Diagnostic
Adds rich metadata to your Error that can be used by Report to print really nice and human-friendly error messages.
SourceCode
Represents readable source code of some sort.
SpanContents
Contents of a SourceCode covered by SourceSpan.

Type Aliases§

ByteOffset
“Raw” type for the byte offset from the beginning of a SourceCode.