neon_runtime/nan/
error.rs

1//! Facilities for creating and throwing JS errors.
2
3use crate::raw::{Isolate, Local};
4
5/// Throws an `Error` object in the current context.
6pub unsafe fn throw(_: Isolate, val: Local) {
7    neon_sys::Neon_Error_Throw(val)
8}
9
10/// Mutates the `out` argument provided to refer to a newly created `Error` object.
11pub unsafe fn new_error(_: Isolate, out: &mut Local, msg: Local) {
12    neon_sys::Neon_Error_NewError(out, msg)
13}
14
15/// Mutates the `out` argument provided to refer to a newly created `TypeError` object.
16pub unsafe fn new_type_error(_: Isolate, out: &mut Local, msg: Local) {
17    neon_sys::Neon_Error_NewTypeError(out, msg)
18}
19
20/// Mutates the `out` argument provided to refer to a newly created `RangeError` object.
21pub unsafe fn new_range_error(_: Isolate, out: &mut Local, msg: Local) {
22    neon_sys::Neon_Error_NewRangeError(out, msg)
23}
24
25/// Throws an `Error` object in the current context.
26pub unsafe fn throw_error_from_utf8(_: Isolate, msg: *const u8, len: i32) {
27    neon_sys::Neon_Error_ThrowErrorFromUtf8(msg, len)
28}