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:
anyhowandcolor-eyre: these two enormously influential error handling libraries have pushed forward the experience of application-level error handling and error reporting.miette’sReporttype is an attempt at a very very rough version of theirReporttypes.thiserrorfor setting the standard for library-level error definitions, and for being the inspiration behindmiette’s derive macro.rustcand @estebank for their state-of-the-art work in compiler diagnostics.ariadnefor 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§
- Debug
Report Handler - [
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. - Graphical
Report Handler - A [
ReportHandler] that displays a givenReportin a quasi-graphical way, using terminal colors, unicode drawing characters, and other such things. - Graphical
Theme - Theme used by
GraphicalReportHandlerto render fancyDiagnosticreports. - JSON
Report Handler - [
ReportHandler] that renders JSON output. It’s a machine-readable output. - Labeled
Span - A labeled
SourceSpan. - Miette
Diagnostic - Diagnostic that can be created at runtime.
- Miette
Span Contents - Basic implementation of the
SpanContentstrait, for convenience. - Named
Source - Utility struct for when you have a regular
SourceCodetype that doesn’t implementname. For exampleString. Or if you want to override thenamereturned by theSourceCode. - Narratable
Report Handler - [
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. - Source
Offset - Newtype that represents the
ByteOffsetfrom the beginning of aSourceCode - Source
Span - Span within a
SourceCode - Theme
Characters - Characters to be used when drawing when using
GraphicalReportHandler. - Theme
Styles - Styles for various parts of graphical rendering for the
GraphicalReportHandler.
Enums§
- Miette
Error - Error enum for miette. Used by certain operations in the protocol.
- Severity
Diagnosticseverity. Intended to be used byReportHandlers to change the way differentDiagnostics are displayed. Defaults toSeverity::Error.
Traits§
- Diagnostic
- Adds rich metadata to your Error that can be used by
Reportto print really nice and human-friendly error messages. - Source
Code - Represents readable source code of some sort.
- Span
Contents - Contents of a
SourceCodecovered bySourceSpan.
Type Aliases§
- Byte
Offset - “Raw” type for the byte offset from the beginning of a
SourceCode.