Crate simple_error

Crate simple_error 

Source
Expand description

A simple error type backed by a string.

This crate provides a SimpleError type, which implements std::error::Error. The underlying type is a String used as the error message.

It should be used when all you care about is an error string.

It should not be used when you want to programmatically handle different kinds of an error.

Macros§

bail
Helper macro for returning a SimpleError constructed from either a Into<SimpleError>, a string slice, or a formatted string.
ensure_with
Helper macro for ensuring a boolean condition while returning early with a newly constructed SimpleError if the condition is false. Can be used in functions that return Result<_, E> where E: From<SimpleError> (e.g. SimpleError or Box<dyn Error>).
map_err_with
Map a result type error to simple error with format
require_with
Helper macro for unwrapping Option values while returning early with a newly constructed SimpleError if the value of the expression is None. Can be used in functions that return Result<_, E> where E: From<SimpleError> (e.g. SimpleError or Box<dyn Error>).
simple_error
Construct an ad-hoc SimpleError from a string.
try_with
Helper macro for unwrapping Result values while returning early with a newly constructed SimpleError if the value of the expression is Err. Can be used in functions that return Result<_, E> where E: From<SimpleError> (e.g. SimpleError or Box<dyn Error>).

Structs§

SimpleError
A type that represents a simple error.

Type Aliases§

SimpleResult
Result type in which the error is a simple error