#[repr(u8)]
#[non_exhaustive]
pub enum Kind {
Show 16 variants Unknown, Internal, Invalid, Unsupported, NotFound, AlreadyExists, ResourceExhausted, Misuse, Cancelled, Shutdown, Timeout, Conflict, Serialization, Io, Protocol, Other,
}
Expand description

Category indicates “what went wrong”, in abstract terms.

Choosing a Kind

  • Kind::Io, Kind::Protocol, and Kind::Other should only be used if there’s no more specific option.

    For example, a network timeout is a type of IO error, however it should use Kind::Timeout rather than Kind::Io.

  • Kind::Invalid should be used when the input will never be valid (at least in this version of the software), rather than input which is invalid because of the current system state.

    For example, an unknown identifier should use Kind::NotFound (for example ockam_vault_core’s Secret) rather than Kind::Invalid,

  • Kind::Cancelled, Kind::Timeout, and Kind::Shutdown all sound similar, but:

    • Kind::Timeout should be used to map operations which timeout externally, such as network requests. These may succeed if retried.

    • Kind::Shutdown should be used to indicate the operation failed due to the node shutting down.

    • Kind::Cancelled is used when a request to cancel the operation comes in while the operation is in progress.

Variants (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

Unknown

Indicates that there is no way to determine a more specific kind.

Internal

Used for serious internal errors, including panics.

This generally should not be used unless we’d accept a bug report for the error.

Invalid

The input was fundamentally invalid.

For example, this is appropriate to use when:

  • A null pointer being passed as input in the FFI.
  • A string is used as input which is not UTF-8.
  • Parse failures of various kinds, but be sure to include more specific information in the Error payload.

Note that it is not appropriate for input which is invalid only due to the current system state.

Unsupported

The requested operation is not supported/implemented by that component.

For example, this is appropriate for a component (for example, a custom Vault) which do not implement the entire API surface.

NotFound

Some referenced entity was not found.

For example, this may be appropriate for:

  • A vault which does not recognize a Secret which it recieves.
  • FFI that recieves an integer handle that does not belong to any known entity.
  • Local Address which don’t correspond to any known Worker or Processor.
  • Address with a transport of an unknown or unsupported type.

Information about what exactly it is that could not be located should be available on the Error itself.

AlreadyExists

The operation failed because

For example, this may be appropriate for:

  • A vault which does not recognize a Secret which it recieves.
  • FFI that recieves an integer handle that does not belong to any known entity.
  • Local Address which don’t correspond to any known Worker or Processor.
  • Address with a transport of an unknown or unsupported type.

Information about what exactly it is that could not be located should be available on the Error itself.

ResourceExhausted

Indicates that some resource has been exhausted, or would be exhausted if the request were to be fulfilled.

The resource in question could be memory, open file descriptors, storage, quota, simultaneous in-flight messages or tasks…

Information about which resource it was that was exhausted should be available on the Error itself.

Misuse

An API was misused in some unspecific fashion.

This is mostly intended for FFI and other non-Rust bindings — for example, it would be appropriate to map core::cell::BorrowError to this.

Cancelled

Indicates the operation failed due to a cancellation request.

See the type documentation on the difference between this, Kind::Shutdown and Kind::Timeout.

Shutdown

Indicates that the operation failed due to the node shutting down.

See the type documentation on the difference between this, Kind::Cancelled and Kind::Timeout.

Timeout

Indicates that the operation failed due to an external operation timing out, such as a network request, which may succeed if retried.

See the type documentation on the difference between this, Kind::Shutdown and Kind::Cancelled.

Conflict

Indicates an operation failed due to simultaneous attempts to modify a resource.

Serialization

Indicates an a failure to deserialize a message (or in rare cases, failure to serialize).

Io

Indicates some other I/O error.

Specifics should be available on error payload.

Protocol

Indicates some other I/O error.

Specifics should be available on error payload.

Other

Indicates an error that

Specifics should be available on error payload.

Implementations

Attempt to construct a Kind from the numeric value.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Try cloning a object and return an Err in case of failure.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more