[][src]Module dangerous::error

Error support.

  • If you want the fastest error which has no debugging information, Fatal or Invalid (retryable) has you covered.
  • If you want an error that is still designed to be fast, but also includes debugging information, Expected will meet your uh, expectations... If the feature full-context is enabled, Expected uses FullContextStack, RootContextStack if not.
  • If you require more verbosity, consider creating custom Contexts before jumping to custom errors. If you do require a custom error, implementing it is easy enough. Just implement WithContext and From for ExpectedValue, ExpectedLength and ExpectedValid and you'll be on your merry way. Additionally implement Details to support lovely error printing and ToRetryRequirement for streaming protocols.

Most of what dangerous supports out of the box is good to go. If you need to stretch out performance more, or provide additional functionality on what is provided, the error system should be flexible for those requirements. If it's not, consider opening an issue.

Structs

Expected

A catch-all error for all expected errors supported in this crate.

ExpectedContext

A sealed expected Context.

ExpectedLength

An error representing a failed requirement for a length of Input.

ExpectedValid

An error representing a failed requirement for a valid Input.

ExpectedValue

An error representing a failed exact value requirement of Input.

Fatal

Fatal contains no details around what went wrong and cannot be retried.

FullContextStackfull-context

A ContextStack that contains all Contexts collected.

Invalid

Invalid contains no details around what went wrong other than a RetryRequirement if the error is not fatal.

RetryRequirement

An indicator of how many bytes are required to continue processing input.

RootContextStack

A ContextStack that only contains the root ExpectedContext.

Traits

Context

The base context surrounding an error.

ContextStack

A walkable stack of Contexts collected from an error.

ContextStackBuilder

A ContextStack builder.

Details

The required details around an error to produce a verbose report on what went wrong when processing input.

Error

Convenience trait requiring WithContext, FromExpected.

FromExpected

Convenience trait requiring From for ExpectedValue, ExpectedLength and ExpectedValid.

ToRetryRequirement

Implemented for errors that return a RetryRequirement.

WithContext

Implemented for errors that collect Contexts.

Type Definitions

ContextStackWalker

A dynamic function for walking a context stack.