Aller au contenu principal

SyntaxError

Alias to native globalThis.SyntaxError

The SyntaxError object represents an error when trying to interpret syntactically invalid code. It is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.

@example
import { SyntaxError } from '@w5s/error';

try {
throw new SyntaxError("Hello");
} catch (e) {
console.log(e instanceof SyntaxError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "SyntaxError"
console.log(e.stack); // Stack of the error
}

Hierarchy

  • Error
    • SyntaxError

Index

Constructors

Properties

Constructors

externalconstructor

  • new SyntaxError(message?: string): SyntaxError
  • new SyntaxError(message?: string, options?: ErrorOptions): SyntaxError

Properties

name

name: SyntaxError
Page Options