pub enum JsError {
Type(String),
Range(String),
Error(String),
Fields(Box<ErrorFields>),
}Expand description
An error of a chosen JS class: what Result<T, JsError> throws, and
what a Later task’s Err(JsError) rejects with (any other error
type is an Error with its message). JsError::with_code and
JsError::with give it properties, as Node’s errors have
(error.code === "ENOENT"; TS: Error & { code?: string }).
Variants§
Type(String)
A TypeError: the call was not allowed or its value is wrong.
Range(String)
A RangeError: a value past a limit.
Error(String)
An Error.
Fields(Box<ErrorFields>)
One of those with properties.
Implementations§
Source§impl JsError
impl JsError
Sourcepub fn with(self, key: &'static str, value: impl Into<JsonValue>) -> Self
pub fn with(self, key: &'static str, value: impl Into<JsonValue>) -> Self
The error with property key set to value (replacing one of the
same name).
Sourcepub fn access_denied(
message: impl Into<String>,
permission: &str,
resource: impl Into<String>,
) -> Self
pub fn access_denied( message: impl Into<String>, permission: &str, resource: impl Into<String>, ) -> Self
What a call the app’s capabilities do not grant fails with, as
Node’s permission model: an Error with code
codes::ACCESS_DENIED, permission (the capability: "fs",
"network", "clipboard", …) and resource (the path, URL or
name asked for; "" when the capability has none).
Trait Implementations§
impl Eq for JsError
Source§impl From<Error> for JsError
An I/O error as Node reports it: Error with the message and the
code of its kind or OS error (ENOENT, EACCES, …; none when it
has no name).
impl From<Error> for JsError
An I/O error as Node reports it: Error with the message and the
code of its kind or OS error (ENOENT, EACCES, …; none when it
has no name).