Struct napi_h::bindgen_prelude::Error
source · pub struct Error<S: AsRef<str> = Status> {
pub status: S,
pub reason: String,
/* private fields */
}
Expand description
Represent JsError
.
Return this Error in js_function
, napi-rs will throw it as JsError
for you.
If you want throw it as TypeError
or RangeError
, you can use JsTypeError/JsRangeError::from(Error).throw_into(env)
Fields§
§status: S
§reason: String
Implementations§
Trait Implementations§
source§impl<S: AsRef<str> + Debug> Error for Error<S>
impl<S: AsRef<str> + Debug> Error for Error<S>
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl Error for Error
impl Error for Error
source§fn custom<T: Display>(msg: T) -> Self
fn custom<T: Display>(msg: T) -> Self
Raised when there is general error when deserializing a type. Read more
source§fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Raised when a
Deserialize
receives a type different from what it was
expecting. Read moresource§fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Raised when a
Deserialize
receives a value of the right type but that
is wrong for some other reason. Read moresource§fn invalid_length(len: usize, exp: &dyn Expected) -> Self
fn invalid_length(len: usize, exp: &dyn Expected) -> Self
Raised when deserializing a sequence or map and the input data contains
too many or too few elements. Read more
source§fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
Raised when a
Deserialize
enum type received a variant with an
unrecognized name.source§fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
Raised when a
Deserialize
struct type received a field with an
unrecognized name.source§fn missing_field(field: &'static str) -> Self
fn missing_field(field: &'static str) -> Self
Raised when a
Deserialize
struct type expected to receive a required
field with a particular name but that field was not present in the
input.source§fn duplicate_field(field: &'static str) -> Self
fn duplicate_field(field: &'static str) -> Self
Raised when a
Deserialize
struct type received more than one of the
same field.source§impl From<Error> for Error
impl From<Error> for Error
source§fn from(value: SerdeJSONError) -> Self
fn from(value: SerdeJSONError) -> Self
Converts to this type from the input type.
source§impl<S: AsRef<str>> From<Infallible> for Error<S>
impl<S: AsRef<str>> From<Infallible> for Error<S>
source§fn from(_: Infallible) -> Self
fn from(_: Infallible) -> Self
Converts to this type from the input type.
source§impl<S: AsRef<str>> ToNapiValue for Error<S>
impl<S: AsRef<str>> ToNapiValue for Error<S>
source§unsafe fn to_napi_value(env: napi_env, val: Self) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: Self) -> Result<napi_value>
Safety Read more
impl<S> Send for Error<S>
impl<S> Sync for Error<S>
Auto Trait Implementations§
impl<S> Freeze for Error<S>where
S: Freeze,
impl<S> RefUnwindSafe for Error<S>where
S: RefUnwindSafe,
impl<S> Unpin for Error<S>where
S: Unpin,
impl<S> UnwindSafe for Error<S>where
S: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more