ArgumentError
Extends
Section titled “Extends”TypeError
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ArgumentError(
message?):ArgumentError
Parameters
Section titled “Parameters”message?
Section titled “message?”string
Returns
Section titled “Returns”ArgumentError
Inherited from
Section titled “Inherited from”TypeError.constructor
Constructor
Section titled “Constructor”new ArgumentError(
message?,options?):ArgumentError
Parameters
Section titled “Parameters”message?
Section titled “message?”string
options?
Section titled “options?”ErrorOptions
Returns
Section titled “Returns”ArgumentError
Inherited from
Section titled “Inherited from”TypeError.constructor
Constructor
Section titled “Constructor”new ArgumentError(
message?):ArgumentError
Parameters
Section titled “Parameters”message?
Section titled “message?”string
Returns
Section titled “Returns”ArgumentError
Inherited from
Section titled “Inherited from”TypeError.constructor
Constructor
Section titled “Constructor”new ArgumentError(
message?,options?):ArgumentError
Parameters
Section titled “Parameters”message?
Section titled “message?”string
options?
Section titled “options?”ErrorOptions
Returns
Section titled “Returns”ArgumentError
Inherited from
Section titled “Inherited from”TypeError.constructor
Properties
Section titled “Properties”cause?
Section titled “cause?”
optionalcause?:unknown
Inherited from
Section titled “Inherited from”TypeError.cause
message
Section titled “message”message:
string
Inherited from
Section titled “Inherited from”TypeError.message
name:
"ArgumentError"=ArgumentError.NAME
Overrides
Section titled “Overrides”TypeError.name
stack?
Section titled “stack?”
optionalstack?:string
Inherited from
Section titled “Inherited from”TypeError.stack
readonlystaticNAME:"ArgumentError"="ArgumentError"
stackTraceLimit
Section titled “stackTraceLimit”
staticstackTraceLimit:number
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Section titled “Inherited from”TypeError.stackTraceLimit
Methods
Section titled “Methods”assert()
Section titled “assert()”Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is undefined
Parameters
Section titled “Parameters”any
string
"undefined"
Returns
Section titled “Returns”asserts value is undefined
Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is null
Parameters
Section titled “Parameters”any
string
"null"
Returns
Section titled “Returns”asserts value is null
Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is boolean
Parameters
Section titled “Parameters”any
string
"boolean"
Returns
Section titled “Returns”asserts value is boolean
Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is number
Parameters
Section titled “Parameters”any
string
"number"
Returns
Section titled “Returns”asserts value is number
Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is { [key: string]: any }
Parameters
Section titled “Parameters”any
string
"object"
Returns
Section titled “Returns”asserts value is { [key: string]: any }
Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is string
Parameters
Section titled “Parameters”any
string
"string"
Returns
Section titled “Returns”asserts value is string
Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is any[]
Parameters
Section titled “Parameters”any
string
"Array"
Returns
Section titled “Returns”asserts value is any[]
Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is ArrayBuffer
Parameters
Section titled “Parameters”any
string
"ArrayBuffer"
Returns
Section titled “Returns”asserts value is ArrayBuffer
Call Signature
Section titled “Call Signature”
staticassert(value,name,type):asserts value is ArrayBufferView<ArrayBufferLike>
Parameters
Section titled “Parameters”any
string
"ArrayBufferView"
Returns
Section titled “Returns”asserts value is ArrayBufferView<ArrayBufferLike>
Call Signature
Section titled “Call Signature”
staticassert<T>(value,name,type):asserts value is T
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”any
string
new (…args) => T
Returns
Section titled “Returns”asserts value is T
Call Signature
Section titled “Call Signature”
staticassert(value,name,type, …types):void
Parameters
Section titled “Parameters”any
string
…ArgumentType[]
Returns
Section titled “Returns”void
captureStackTrace()
Section titled “captureStackTrace()”
staticcaptureStackTrace(targetObject,constructorOpt?):void
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};Error.captureStackTrace(myObject);myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() { b();}
function b() { c();}
function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error;}
a();Parameters
Section titled “Parameters”targetObject
Section titled “targetObject”object
constructorOpt?
Section titled “constructorOpt?”Function
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”TypeError.captureStackTrace
isType()
Section titled “isType()”Call Signature
Section titled “Call Signature”
staticisType(value,type):value is undefined
Parameters
Section titled “Parameters”any
"undefined"
Returns
Section titled “Returns”value is undefined
Call Signature
Section titled “Call Signature”
staticisType(value,type):value is null
Parameters
Section titled “Parameters”any
"null"
Returns
Section titled “Returns”value is null
Call Signature
Section titled “Call Signature”
staticisType(value,type):value is boolean
Parameters
Section titled “Parameters”any
"boolean"
Returns
Section titled “Returns”value is boolean
Call Signature
Section titled “Call Signature”
staticisType(value,type):value is number
Parameters
Section titled “Parameters”any
"number"
Returns
Section titled “Returns”value is number
Call Signature
Section titled “Call Signature”
staticisType(value,type):value is object
Parameters
Section titled “Parameters”any
"object"
Returns
Section titled “Returns”value is object
Call Signature
Section titled “Call Signature”
staticisType(value,type):value is string
Parameters
Section titled “Parameters”any
"string"
Returns
Section titled “Returns”value is string
Call Signature
Section titled “Call Signature”
staticisType(value,type):value is any[]
Parameters
Section titled “Parameters”any
"Array"
Returns
Section titled “Returns”value is any[]
Call Signature
Section titled “Call Signature”
staticisType(value,type):value is ArrayBuffer
Parameters
Section titled “Parameters”any
"ArrayBuffer"
Returns
Section titled “Returns”value is ArrayBuffer
Call Signature
Section titled “Call Signature”
staticisType(value,type):value is ArrayBufferView<ArrayBufferLike>
Parameters
Section titled “Parameters”any
"ArrayBufferView"
Returns
Section titled “Returns”value is ArrayBufferView<ArrayBufferLike>
Call Signature
Section titled “Call Signature”
staticisType<T>(value,type):value is T
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”any
new (…args) => T
Returns
Section titled “Returns”value is T
Call Signature
Section titled “Call Signature”
staticisType(value,type):boolean
Parameters
Section titled “Parameters”any
Returns
Section titled “Returns”boolean
prepareStackTrace()
Section titled “prepareStackTrace()”
staticprepareStackTrace(err,stackTraces):any
Parameters
Section titled “Parameters”Error
stackTraces
Section titled “stackTraces”CallSite[]
Returns
Section titled “Returns”any
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Section titled “Inherited from”TypeError.prepareStackTrace