pub struct ErrorBuilder { /* private fields */ }
Expand description

A convenience type for building a structured error type

Implementations

does the builder contain any error messages, used to short circuit various functions if no error has been detected.

Consume the builder and produce a Result

let e = Error::build()
    .at_named("a", "flat out broken")
    .build();
assert!(e.is_err());

extend the existing builder with an error at the specified location

extend an existing builder with an error at a named location

let e = Error::build()
    .at_named("field_1", "should be empty")
    .build();

extend an existing builder with an error at an indexed location

let e = Error::build()
    .at_index(1, "value should be even")
    .build();

extend the existing builder at the specified location if the result is an error

let e = Error::build()
    .try_at_location(Location::Index(1), Ok(()))
    .build();
assert!(e.is_ok());

extend an existing builder with an error at a named location if the result is an error

let e = Error::build()
    .try_at_named("field", Ok(()))
    .build();
assert!(e.is_ok());

extend an existing builder with an error at an indexed location if the result is an error

let e = Error::build()
    .try_at_index(42, Ok(()))
    .build();
assert!(e.is_ok());

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.