#[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
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.
Implementations§
Source§impl Error
impl Error
Sourcepub fn to_js_value(&self) -> JsValue
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 Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Infallible> for Error
impl From<Infallible> for Error
Source§fn from(_value: Infallible) -> Self
fn from(_value: Infallible) -> Self
Source§impl From<InsertError> for Error
impl From<InsertError> for Error
Source§fn from(e: InsertError) -> Self
fn from(e: InsertError) -> Self
Source§impl From<InvalidHeaderName> for Error
Available on crate feature http only.
impl From<InvalidHeaderName> for Error
http only.Source§fn from(value: InvalidHeaderName) -> Self
fn from(value: InvalidHeaderName) -> Self
Source§impl From<InvalidHeaderValue> for Error
Available on crate feature http only.
impl From<InvalidHeaderValue> for Error
http only.Source§fn from(value: InvalidHeaderValue) -> Self
fn from(value: InvalidHeaderValue) -> Self
Source§impl From<InvalidStatusCode> for Error
Available on crate feature http only.
impl From<InvalidStatusCode> for Error
http only.Source§fn from(value: InvalidStatusCode) -> Self
fn from(value: InvalidStatusCode) -> Self
Source§impl From<ParseError> for Error
Available on crate feature timezone only.
impl From<ParseError> for Error
timezone only.