pub struct JsError(/* private fields */);Expand description
The type of JavaScript
Error
objects.
§Example
// Create a type error:
let err = cx.type_error("expected a number, found a string")?;
// Add some custom diagnostic properties to the error:
err.prop(&mut cx, "expected").set("number")?;
err.prop(&mut cx, "found").set("string")?;
// Throw the error:
cx.throw(err)?;Implementations§
Source§impl JsError
impl JsError
Sourcepub fn error<'a, C: Context<'a>, S: AsRef<str>>(
cx: &mut C,
msg: S,
) -> NeonResult<Handle<'a, JsError>>
pub fn error<'a, C: Context<'a>, S: AsRef<str>>( cx: &mut C, msg: S, ) -> NeonResult<Handle<'a, JsError>>
Creates a direct instance of the Error class.
See also: Context::error
Sourcepub fn type_error<'a, C: Context<'a>, S: AsRef<str>>(
cx: &mut C,
msg: S,
) -> NeonResult<Handle<'a, JsError>>
pub fn type_error<'a, C: Context<'a>, S: AsRef<str>>( cx: &mut C, msg: S, ) -> NeonResult<Handle<'a, JsError>>
Creates an instance of the TypeError class.
See also: Context::type_error
Sourcepub fn range_error<'a, C: Context<'a>, S: AsRef<str>>(
cx: &mut C,
msg: S,
) -> NeonResult<Handle<'a, JsError>>
pub fn range_error<'a, C: Context<'a>, S: AsRef<str>>( cx: &mut C, msg: S, ) -> NeonResult<Handle<'a, JsError>>
Creates an instance of the RangeError class.
See also: Context::range_error
Trait Implementations§
Source§impl Object for JsError
impl Object for JsError
Source§fn prop<'a, 'cx: 'a, K: PropertyKey>(
&self,
cx: &'a mut Cx<'cx>,
key: K,
) -> PropOptions<'a, 'cx, Self, K>
fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>
Create a
PropOptions for accessing a property. Read moreSource§fn method<'a, 'cx: 'a, K: PropertyKey>(
&self,
cx: &'a mut Cx<'cx>,
key: K,
) -> NeonResult<BindOptions<'a, 'cx>>
fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>
Gets a property from the object as a method and binds
this to the object. Read moreSource§fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K,
) -> NeonResult<Option<Handle<'a, V>>>
fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>
👎Deprecating in a future version: use
Object::prop() insteadSource§fn get_value<'a, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K,
) -> NeonResult<Handle<'a, JsValue>>
fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>
👎Deprecating in a future version: use
Object::prop() insteadSource§fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>(
&self,
cx: &mut C,
key: K,
) -> NeonResult<Handle<'a, V>>
fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>
👎Deprecating in a future version: use
Object::prop() insteadSource§fn get_own_property_names<'a, C: Context<'a>>(
&self,
cx: &mut C,
) -> JsResult<'a, JsArray>
fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>
Available on crate feature
napi-6 only.fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>
fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>
Source§fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>(
&self,
cx: &mut C,
key: K,
val: Handle<'_, W>,
) -> NeonResult<bool>
fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>
👎Deprecating in a future version: use
Object::prop() insteadfn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>
Source§fn call_method_with<'a, C, K>(
&self,
cx: &mut C,
method: K,
) -> NeonResult<CallOptions<'a>>where
C: Context<'a>,
K: PropertyKey,
fn call_method_with<'a, C, K>(
&self,
cx: &mut C,
method: K,
) -> NeonResult<CallOptions<'a>>where
C: Context<'a>,
K: PropertyKey,
👎Deprecating in a future version: use
Object::method() insteadSource§impl Value for JsError
impl Value for JsError
Auto Trait Implementations§
impl Freeze for JsError
impl RefUnwindSafe for JsError
impl !Send for JsError
impl !Sync for JsError
impl Unpin for JsError
impl UnwindSafe for JsError
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more