File: syntax_error.md

package info (click to toggle)
node-addon-api 8.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,248 kB
  • sloc: cpp: 15,431; javascript: 5,631; ansic: 157; makefile: 7
file content (66 lines) | stat: -rw-r--r-- 1,726 bytes parent folder | download
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# SyntaxError

The `Napi::SyntaxError` class is a representation of the JavaScript
`SyntaxError` that is thrown when the engine encounters tokens or token order
that does not conform to the syntax of the language when parsing code.

The `Napi::SyntaxError` class inherits its behaviors from the `Napi::Error`
class (for more info see: [`Napi::Error`](error.md)).

For more details about error handling refer to the section titled [Error
handling](error_handling.md).

## Methods

### New

Creates a new instance of a `Napi::SyntaxError` object.

```cpp
Napi::SyntaxError::New(Napi::Env env, const char* message);
```

- `[in] Env`: The environment in which to construct the `Napi::SyntaxError`
  object.
- `[in] message`: Null-terminated string to be used as the message for the
  `Napi::SyntaxError`.

Returns an instance of a `Napi::SyntaxError` object.

### New

Creates a new instance of a `Napi::SyntaxError` object.

```cpp
Napi::SyntaxError::New(Napi::Env env, const std::string& message);
```

- `[in] Env`: The environment in which to construct the `Napi::SyntaxError`
  object.
- `[in] message`: Reference string to be used as the message for the
  `Napi::SyntaxError`.

Returns an instance of a `Napi::SyntaxError` object.

### Constructor

Creates a new empty instance of a `Napi::SyntaxError`.

```cpp
Napi::SyntaxError::SyntaxError();
```

### Constructor

Initializes a `Napi::SyntaxError` instance from an existing Javascript error
object.

```cpp
Napi::SyntaxError::SyntaxError(napi_env env, napi_value value);
```

- `[in] Env`: The environment in which to construct the `Napi::SyntaxError`
  object.
- `[in] value`: The `Napi::Error` reference to wrap.

Returns an instance of a `Napi::SyntaxError` object.