Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 25 variants BadEncoding, BodyUsed, Json((String, u16)), JsError(String), Http(Error), Infallible, Internal(JsValue), Io(Error), BindingError(String), RouteInsertError(InsertError), RouteNoDataError, RustError(String), SerdeJsonError(Error), SerdeWasmBindgenError(Error), StatusCode(InvalidStatusCode), D1(D1Error), Utf8Error(Utf8Error), TimezoneError, KvError(KvError), EmailRecipientSuppressed(String), EmailRecipientNotAllowed(String), RateLimitExceeded(String), DailyLimitExceeded(String), InternalError(String), UnknownJsError { original: JsValue, name: Option<String>, message: String, code: Option<String>, cause: Option<Box<Error>>, },
}
Expand description

All possible Error variants that might be encountered while working with a Worker.

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

BadEncoding

§

BodyUsed

§

Json((String, u16))

§

JsError(String)

Error used for strings thrown from JS

§

Http(Error)

§

Infallible

§

Internal(JsValue)

Error used for unknown JS values thrown from JS

§

Io(Error)

§

BindingError(String)

§

RouteInsertError(InsertError)

§

RouteNoDataError

§

RustError(String)

§

SerdeJsonError(Error)

§

SerdeWasmBindgenError(Error)

§

StatusCode(InvalidStatusCode)

§

D1(D1Error)

§

Utf8Error(Utf8Error)

§

TimezoneError

§

KvError(KvError)

§

EmailRecipientSuppressed(String)

Email recipient is on the suppression list (typically due to prior bounces or complaints) and cannot be delivered to.

§

EmailRecipientNotAllowed(String)

Email recipient is not allowed for this sender (policy/restriction).

Distinct from EmailRecipientSuppressed: suppression is a delivery outcome, “not allowed” is a sender-policy refusal.

§

RateLimitExceeded(String)

Cloudflare rate limit exceeded.

Currently only produced by the email forwarder. May be produced by other rate-limited subsystems in the future.

§

DailyLimitExceeded(String)

Cloudflare daily limit exceeded.

Currently only produced by the email forwarder. May be produced by other quota-limited subsystems in the future.

§

InternalError(String)

A backend Cloudflare service reported an internal error.

Generally transient; consider retrying with backoff.

Currently only produced by the email forwarder. May be produced by other subsystems in the future.

§

UnknownJsError

A JavaScript error that didn’t match any structured variant.

This is the catch-all for errors thrown by the Workers runtime or user code that don’t carry a recognized error code.

Always produced by converting from a JsValue; not intended to be constructed directly from Rust code. Round-tripping back to JsValue returns the stored original, so the original error object identity (stack, prototype, extra properties) is preserved.

Fields

§original: JsValue

The original error value.

§name: Option<String>

Cached name extracted at conversion time.

§message: String

Cached message extracted at conversion time.

§code: Option<String>

Cached code extracted at conversion time.

§cause: Option<Box<Error>>

Recursively converted cause.

Implementations§

Source§

impl Error

Source

pub fn to_js_value(&self) -> JsValue

Build a JsValue representation of this error without consuming it.

For variants holding a stored JsValue (UnknownJsError, Internal), this clones the original — cheap, since JsValue::clone is a refcount bump on the V8 anchor table. Other variants reconstruct a fresh js_sys::Error with the same code/message as the consuming From<Error> for JsValue impl.

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, f: &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
Source§

impl<'_derivative_strum> From<&'_derivative_strum Error> for &'static str

Source§

fn from(x: &'_derivative_strum Error) -> &'static str

Converts to this type from the input type.
Source§

impl From<&str> for Error

Source§

fn from(a: &str) -> Self

Converts to this type from the input type.
Source§

impl From<D1Error> for Error

Available on crate feature d1 only.
Source§

fn from(e: D1Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for &'static str

Source§

fn from(x: Error) -> &'static str

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Available on crate feature http only.
Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for JsValue

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Infallible> for Error

Source§

fn from(_value: Infallible) -> Self

Converts to this type from the input type.
Source§

impl From<InsertError> for Error

Source§

fn from(e: InsertError) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidHeaderName> for Error

Available on crate feature http only.
Source§

fn from(value: InvalidHeaderName) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidHeaderValue> for Error

Available on crate feature http only.
Source§

fn from(value: InvalidHeaderValue) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidStatusCode> for Error

Available on crate feature http only.
Source§

fn from(value: InvalidStatusCode) -> Self

Converts to this type from the input type.
Source§

impl From<JsValue> for Error

Source§

fn from(v: JsValue) -> Self

Converts to this type from the input type.
Source§

impl From<KvError> for Error

Source§

fn from(e: KvError) -> Self

Converts to this type from the input type.
Source§

impl From<ParseError> for Error

Available on crate feature timezone only.
Source§

fn from(_value: ParseError) -> Self

Converts to this type from the input type.
Source§

impl From<ParseError> for Error

Source§

fn from(e: ParseError) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Error

Source§

fn from(a: String) -> Self

Converts to this type from the input type.
Source§

impl From<Utf8Error> for Error

Source§

fn from(value: Utf8Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl !UnwindSafe 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, 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> Same for T

Source§

type Output = T

Should always be Self
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 = 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 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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more