1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Facilities for creating and throwing JS errors.

use raw::{Isolate, Local};

/// Throws an `Error` object in the current context.
pub unsafe fn throw(_: Isolate, val: Local) {
    neon_sys::Neon_Error_Throw(val)
}

/// Mutates the `out` argument provided to refer to a newly created `Error` object.
pub unsafe fn new_error(_: Isolate, out: &mut Local, msg: Local) {
    neon_sys::Neon_Error_NewError(out, msg)
}

/// Mutates the `out` argument provided to refer to a newly created `TypeError` object.
pub unsafe fn new_type_error(_: Isolate, out: &mut Local, msg: Local) {
    neon_sys::Neon_Error_NewTypeError(out, msg)
}

/// Mutates the `out` argument provided to refer to a newly created `RangeError` object.
pub unsafe fn new_range_error(_: Isolate, out: &mut Local, msg: Local) {
    neon_sys::Neon_Error_NewRangeError(out, msg)
}

/// Throws an `Error` object in the current context.
pub unsafe fn throw_error_from_utf8(_: Isolate, msg: *const u8, len: i32) {
    neon_sys::Neon_Error_ThrowErrorFromUtf8(msg, len)
}