Crate tectonic_errors

source ·
Expand description

Generic error handling for Tectonic.

This crate provides a generic boxed error type, plus supporting utilities. In particular:

  • The basic Error type is an anyhow 1.x boxed Error
  • The atry! macro allows simple structured annotations to be added to ? operations
  • The a_ok_or! macro allows for annotations to Option::ok_or_else calls.



  • A “prelude” module providing a collection of useful names, without causing compiler complaints about the ones you don’t use.


  • “annotated ok_or” — like Option::ok_or_else()?, but with the ability to add extended context to the error. This yields an AnnotatedMessage as its error type.
  • “Annotated try” — like try!, but with the ability to add extended context to the error message. This tries to provide a bit more syntactic sugar than anyhow’s with_context(), and it supports our AnnotatedMessage context type.


  • A simple annotated message that can be attached to errors using the anyhow::Context methods, or be used as an error type itself. The recommended way to use this for error context is using atry! or related macros.
  • The generic error type, for complex operations that can fail for a wide range of reasons. This type is a reexport of the anyhow 1.x series Error type.

Type Definitions

  • A preloaded result type where the error type is our generic error type. Result<T, Error>