1# SyntaxError
2
3The `Napi::SyntaxError` class is a representation of the JavaScript
4`SyntaxError` that is thrown when the engine encounters tokens or token order
5that does not conform to the syntax of the language when parsing code.
6
7The `Napi::SyntaxError` class inherits its behaviors from the `Napi::Error`
8class (for more info see: [`Napi::Error`](error.md)).
9
10For more details about error handling refer to the section titled [Error
11handling](error_handling.md).
12
13## Methods
14
15### New
16
17Creates a new instance of a `Napi::SyntaxError` object.
18
19```cpp
20Napi::SyntaxError::New(Napi::Env env, const char* message);
21```
22
23- `[in] Env`: The environment in which to construct the `Napi::SyntaxError`
24  object.
25- `[in] message`: Null-terminated string to be used as the message for the
26  `Napi::SyntaxError`.
27
28Returns an instance of a `Napi::SyntaxError` object.
29
30### New
31
32Creates a new instance of a `Napi::SyntaxError` object.
33
34```cpp
35Napi::SyntaxError::New(Napi::Env env, const std::string& message);
36```
37
38- `[in] Env`: The environment in which to construct the `Napi::SyntaxError`
39  object.
40- `[in] message`: Reference string to be used as the message for the
41  `Napi::SyntaxError`.
42
43Returns an instance of a `Napi::SyntaxError` object.
44
45### Constructor
46
47Creates a new empty instance of a `Napi::SyntaxError`.
48
49```cpp
50Napi::SyntaxError::SyntaxError();
51```
52
53### Constructor
54
55Initializes a `Napi::SyntaxError` instance from an existing Javascript error
56object.
57
58```cpp
59Napi::SyntaxError::SyntaxError(napi_env env, napi_value value);
60```
61
62- `[in] Env`: The environment in which to construct the `Napi::SyntaxError`
63  object.
64- `[in] value`: The `Napi::Error` reference to wrap.
65
66Returns an instance of a `Napi::SyntaxError` object.
67