Skip to main content
Version: 1.4.0

SyntaxError

The SyntaxError constructor creates a new error object that represents an error when trying to interpret syntactically invalid code.

Syntax

new SyntaxError()
new SyntaxError(message)
new SyntaxError(message, options)
new SyntaxError(message, fileName)
new SyntaxError(message, fileName, lineNumber)

SyntaxError()
SyntaxError(message)
SyntaxError(message, options)
SyntaxError(message, fileName)
SyntaxError(message, fileName, lineNumber)

Note: SyntaxError() can be called with or without new. Both create a new SyntaxError instance.

Parameters

  • message optional
    • : Human-readable description of the error
  • options optional
    • : An object that has the following properties:
      • cause optional
        • : A property indicating the specific cause of the error. When catching and re-throwing an error with a more-specific or useful error message, this property can be used to pass the original error.