Struct sandwich::Error

source ·
pub struct Error(/* private fields */);
Expand description

An error. An Error holds a chain of ProtoBasedErrorCode.

Implementations§

source§

impl Error

Implements Error.

source

pub fn iter(&self) -> Iter<'_, ErrorCode>

Returns an iterator over the ProtoBasedErrorCode from the chain.

source

pub fn len(&self) -> usize

Returns the length of the chain.

source

pub fn is_empty(&self) -> bool

Returns the emptiness of the chain.

source

pub fn is(&self, other: &Self) -> bool

Verifies that two Error share the same protobuf based error codes.

Trait Implementations§

source§

impl Debug for Error

Implements std::fmt::Debug for Error.

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Error

Implements std::fmt::Display for Error.

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Error for Error

Implements std::error::Error for Error.

1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl<'s, ErrorEnum: AllowedProtoBasedErrorCodeEnum, S> From<(ErrorEnum, &'s S)> for Errorwhere S: AsRef<str> + 's, ErrorCode: From<(ErrorEnum, &'s S)>,

Instantiates an Error from an enum value and a string.

source§

fn from((e, s): (ErrorEnum, &'s S)) -> Self

Converts to this type from the input type.
source§

impl<'s, ErrorEnum: AllowedProtoBasedErrorCodeEnum> From<(ErrorEnum, &'s str)> for Errorwhere ErrorCode: From<(ErrorEnum, &'s str)>,

Instantiates an Error from an enum value and a string.

source§

fn from((e, s): (ErrorEnum, &'s str)) -> Self

Converts to this type from the input type.
source§

impl<ErrorEnum: AllowedProtoBasedErrorCodeEnum> From<(ErrorEnum, String)> for Errorwhere ErrorCode: From<(ErrorEnum, String)>,

Instantiates an Error from an enum value and a string.

source§

fn from((e, s): (ErrorEnum, String)) -> Self

Converts to this type from the input type.
source§

impl<S> From<(ProtoBasedErrorCode, &S)> for Errorwhere S: AsRef<str>,

Instantiates an Error from an enum value and a string.

source§

fn from((e, s): (ProtoBasedErrorCode, &S)) -> Self

Converts to this type from the input type.
source§

impl From<(ProtoBasedErrorCode, &str)> for Error

Instantiates an Error from an enum value and a string.

source§

fn from((e, s): (ProtoBasedErrorCode, &str)) -> Self

Converts to this type from the input type.
source§

impl From<(ProtoBasedErrorCode, String)> for Error

Instantiates an Error from an enum value and a string.

source§

fn from((e, s): (ProtoBasedErrorCode, String)) -> Self

Converts to this type from the input type.
source§

impl From<ErrorCode> for Error

Instantiates an Error from an ErrorCode.

source§

fn from(e: ErrorCode) -> Self

Converts to this type from the input type.
source§

impl<ErrorEnum: AllowedProtoBasedErrorCodeEnum> From<ErrorEnum> for Errorwhere ErrorCode: From<ErrorEnum>,

Instantiates an Error from an enum value.

source§

fn from(e: ErrorEnum) -> Self

Converts to this type from the input type.
source§

impl From<ProtoBasedErrorCode> for Error

Instantiates an Error from an ProtoBasedErrorCode.

source§

fn from(e: ProtoBasedErrorCode) -> Self

Converts to this type from the input type.
source§

impl<'s, ErrorEnum: AllowedProtoBasedErrorCodeEnum, S> Shr<(ErrorEnum, &'s S)> for Errorwhere ErrorCode: From<(ErrorEnum, &'s S)>, S: AsRef<str> + 's,

Appends an Error into the chain, using the >> operator and a string.

§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, (e, s): (ErrorEnum, &'s S)) -> Self::Output

Performs the >> operation. Read more
source§

impl<'s, ErrorEnum: AllowedProtoBasedErrorCodeEnum> Shr<(ErrorEnum, &'s str)> for Errorwhere ErrorCode: From<(ErrorEnum, &'s str)>,

Appends an Error into the chain, using the >> operator and a string.

§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, (e, s): (ErrorEnum, &'s str)) -> Self::Output

Performs the >> operation. Read more
source§

impl<ErrorEnum: AllowedProtoBasedErrorCodeEnum> Shr<(ErrorEnum, String)> for Errorwhere ErrorCode: From<(ErrorEnum, String)>,

Appends an Error into the chain, using the >> operator and a string.

§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, (e, s): (ErrorEnum, String)) -> Self::Output

Performs the >> operation. Read more
source§

impl<S> Shr<(ProtoBasedErrorCode, &S)> for Errorwhere S: AsRef<str>,

Appends an Error into the chain, using the >> operator and a string.

§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, (e, s): (ProtoBasedErrorCode, &S)) -> Self::Output

Performs the >> operation. Read more
source§

impl Shr<(ProtoBasedErrorCode, &str)> for Error

Appends an Error into the chain, using the >> operator and a string.

§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, (e, s): (ProtoBasedErrorCode, &str)) -> Self::Output

Performs the >> operation. Read more
source§

impl Shr<(ProtoBasedErrorCode, String)> for Error

Appends an Error into the chain, using the >> operator.

§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, (e, s): (ProtoBasedErrorCode, String)) -> Self::Output

Performs the >> operation. Read more
source§

impl Shr<ErrorCode> for Error

Appends an Error into the chain, using the >> operator.

§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, e: ErrorCode) -> Self::Output

Performs the >> operation. Read more
source§

impl<ErrorEnum: AllowedProtoBasedErrorCodeEnum> Shr<ErrorEnum> for Errorwhere ErrorCode: From<ErrorEnum>,

Appends an Error into the chain, using the >> operator.

The >> operator is used to easily build a chain of error: child_error -> parent_error, where child_error is more precise than parent_error.

Example

  // Creates a new Error.
  let e = Error::from(pb::ASN1Error::ASN1ERROR_INVALID_FORMAT);
  // Creates a new Error, "invalid certificate", and appends the previous one.
  let e = e >> pb::CertificateError::CERTIFICATEERROR_MALFORMED;

  // Now, the error chain is the following:
  // CertificateError::CERTIFICATEERROR_MALFORMED -> ASN1Error>>ASN1ERROR_INVALID_FORMAT
  // It is read as "a certificate error occurred: malformed certificate,
  // because: an ASN.1 error occurred: invalid format".
§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, e: ErrorEnum) -> Self::Output

Performs the >> operation. Read more
source§

impl Shr<ProtoBasedErrorCode> for Error

Appends an Error into the chain, using the >> operator.

§

type Output = Error

The resulting type after applying the >> operator.
source§

fn shr(self, e: ProtoBasedErrorCode) -> Self::Output

Performs the >> operation. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.