Enum ockam_core::errcode::Kind
source · [−]#[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
, andKind::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 thanKind::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 exampleockam_vault_core
’sSecret
) rather thanKind::Invalid
, -
Kind::Cancelled
,Kind::Timeout
, andKind::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
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 knownWorker
orProcessor
. 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 knownWorker
orProcessor
. 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
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Kind
impl<'de> Deserialize<'de> for Kind
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
sourceimpl Ord for Kind
impl Ord for Kind
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl PartialOrd<Kind> for Kind
impl PartialOrd<Kind> for Kind
sourcefn partial_cmp(&self, other: &Kind) -> Option<Ordering>
fn partial_cmp(&self, other: &Kind) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more