Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 26 variants EmptyGroup { type_name: &'static str, }, GroupMemberTypeMismatch { expected: &'static str, actual: &'static str, }, AlreadyProvided(&'static str), AlreadyProvidedPrivate { module: &'static str, type_name: &'static str, }, Cycle(String), NotConstructed(&'static str), MissingProvider { type_name: &'static str, module: &'static str, }, ProviderMissingDep { provider: &'static str, module: &'static str, dependency: &'static str, }, InvokerMissingDep { module: &'static str, dependency: &'static str, }, Downcast(&'static str), ConstructorFailed { type_name: &'static str, source: BoxError, }, InvokerFailed { name: &'static str, source: BoxError, }, AppendAfterStart, AppendWhileStopping, BuildTimeout(Duration), StartTimeout(Duration), StopTimeout(Duration), UnwindTimeout(Duration), TaskFailedDuringStart, SigintListen(Error), SigtermListen(Error), SignalListen(Error), MultipleStop(MultipleStopError), CleanupAfterFailure { cleanup: Box<Error>, earlier: Box<Error>, }, Hook { name: &'static str, source: BoxError, }, Io { context: String, source: Error, },
}
Expand description

Errors produced while wiring, starting, or stopping an application.

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.
§

EmptyGroup

A required group has no members.

Fields

§type_name: &'static str

Group type name shown in diagnostics (Group<T>).

§

GroupMemberTypeMismatch

A group member provider’s result type does not match the declared element type.

Fields

§expected: &'static str

Element type the caller declared.

§actual: &'static str

Result type reported by the erased provider.

§

AlreadyProvided(&'static str)

A public type was registered more than once.

§

AlreadyProvidedPrivate

A private type was registered more than once in the same module.

Fields

§module: &'static str

Module name shown in diagnostics.

§type_name: &'static str

Type name that collided.

§

Cycle(String)

The dependency graph contains a cycle.

§

NotConstructed(&'static str)

A value was requested before it had been constructed.

§

MissingProvider

No provider exists for a requested type.

Fields

§type_name: &'static str

Missing type.

§module: &'static str

Scope that requested it.

§

ProviderMissingDep

A provider depends on something nothing registers.

Fields

§provider: &'static str

Provider result type.

§module: &'static str

Module that owns the provider.

§dependency: &'static str

Missing dependency type.

§

InvokerMissingDep

An invoker depends on something nothing registers.

Fields

§module: &'static str

Module that owns the invoker.

§dependency: &'static str

Missing dependency type.

§

Downcast(&'static str)

Internal downcast of a cached value failed.

§

ConstructorFailed

A fallible constructor returned an error.

Fields

§type_name: &'static str

Type being constructed.

§source: BoxError

The user error from the constructor.

§

InvokerFailed

A fallible invoker returned an error.

Fields

§name: &'static str

Rust type name of the invoker function.

§source: BoxError

The user error from the invoker.

§

AppendAfterStart

Hook registration after start completed.

§

AppendWhileStopping

Hook registration while stopping.

§

BuildTimeout(Duration)

Graph construction exceeded its budget.

§

StartTimeout(Duration)

Start phase exceeded its budget.

§

StopTimeout(Duration)

Stop phase exceeded its budget.

§

UnwindTimeout(Duration)

Unwind after a failed/cancelled start exceeded its budget.

§

TaskFailedDuringStart

A background crate::task failed while start was still running, and unwind did not surface a more specific join error.

§

SigintListen(Error)

Failed to install a SIGINT listener.

§

SigtermListen(Error)

Failed to install a SIGTERM listener.

§

SignalListen(Error)

Failed to install a process-signal listener (non-Unix platforms).

§

MultipleStop(MultipleStopError)

Several OnStop hooks failed; see MultipleStopError::errors.

§

CleanupAfterFailure

Cleanup failed after an earlier phase error; both are retained.

Fields

§cleanup: Box<Error>

Error from stop/unwind.

§earlier: Box<Error>

Error from the earlier phase.

§

Hook

An application hook returned this failure.

Prefer Error::hook rather than constructing this variant directly. crate::Lifecycle overwrites Self::Hook::name with the registering hook’s Hook::name when start/stop returns this variant. Error::Io and other variants are left unchanged.

Fields

§name: &'static str

crate::Hook::name; defaults to "unnamed" from Error::hook until crate::Lifecycle attaches the registering hook’s name.

§source: BoxError

The user error from the hook.

§

Io

I/O failure with a short context label (e.g. bind / serve).

Prefer Error::io rather than constructing this variant directly.

Fields

§context: String

What was being done when I/O failed.

§source: Error

Underlying I/O error.

Implementations§

Source§

impl Error

Source

pub fn hook(err: impl Into<BoxError>) -> Self

Wrap a hook failure, keeping the original error as std::error::Error::source.

Accepts anything convertible to BoxError, including &str, String, std::io::Error, and types that implement std::error::Error. crate::Lifecycle overwrites Self::Hook::name with the registering hook’s Hook::name when start/stop returns this variant.

Source

pub fn io(context: impl Into<String>, source: Error) -> Self

Wrap an I/O failure with a short context label (e.g. "bind 127.0.0.1:3000").

There is no From<std::io::Error> impl, so listener.bind().await? does not compile in a modrun::Result function — map with this helper instead.

Trait Implementations§

Source§

impl 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

Source§

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

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

impl Error for Error

Source§

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

Returns 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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

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

fn in_current_span(self) -> Instrumented<Self> ⓘ

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

impl<T, U> Into<U> for T
where 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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more