Skip to main content
Version: 3.27.2

Error

The Error() constructor creates an error object.

Syntax

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

Error()
Error(message)
Error(message, options)
Error(message, fileName)
Error(message, fileName, lineNumber)

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

Parameters

  • message optional
    • : A human-readable description of the error.
  • options optional
    • : An object that has the following properties:
      • cause optional
        • : A value indicating the specific cause of the error, reflected in the Error.prototype.cause property. 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.