ArgumentError
Extends
TypeError
Constructors
Constructor
new ArgumentError(
message?):ArgumentError
Parameters
message?
string
Returns
ArgumentError
Inherited from
TypeError.constructor
Constructor
new ArgumentError(
message?):ArgumentError
Parameters
message?
string
Returns
ArgumentError
Inherited from
TypeError.constructor
Properties
message
message:
string
Inherited from
TypeError.message
name
name:
"ArgumentError"=ArgumentError.NAME
Overrides
TypeError.name
stack?
optionalstack?:string
Inherited from
TypeError.stack
NAME
readonlystaticNAME:"ArgumentError"="ArgumentError"
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
TypeError.stackTraceLimit
Methods
assert()
Call Signature
staticassert(value,name,type):asserts value is undefined
Parameters
value
any
name
string
type
"undefined"
Returns
asserts value is undefined
Call Signature
staticassert(value,name,type):asserts value is null
Parameters
value
any
name
string
type
"null"
Returns
asserts value is null
Call Signature
staticassert(value,name,type):asserts value is boolean
Parameters
value
any
name
string
type
"boolean"
Returns
asserts value is boolean
Call Signature
staticassert(value,name,type):asserts value is number
Parameters
value
any
name
string
type
"number"
Returns
asserts value is number
Call Signature
staticassert(value,name,type):asserts value is { [key: string]: any }
Parameters
value
any
name
string
type
"object"
Returns
asserts value is { [key: string]: any }
Call Signature
staticassert(value,name,type):asserts value is string
Parameters
value
any
name
string
type
"string"
Returns
asserts value is string
Call Signature
staticassert(value,name,type):asserts value is any[]
Parameters
value
any
name
string
type
"Array"
Returns
asserts value is any[]
Call Signature
staticassert(value,name,type):asserts value is ArrayBuffer
Parameters
value
any
name
string
type
"ArrayBuffer"
Returns
asserts value is ArrayBuffer
Call Signature
staticassert(value,name,type):asserts value is ArrayBufferView<ArrayBufferLike>
Parameters
value
any
name
string
type
"ArrayBufferView"
Returns
asserts value is ArrayBufferView<ArrayBufferLike>
Call Signature
staticassert<T>(value,name,type):asserts value is T
Type Parameters
T
T
Parameters
value
any
name
string
type
(...args) => T
Returns
asserts value is T
Call Signature
staticassert(value,name,type, ...types):void
Parameters
value
any
name
string
type
types
...ArgumentType[]
Returns
void
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
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
TypeError.captureStackTrace
isType()
Call Signature
staticisType(value,type):value is undefined
Parameters
value
any
type
"undefined"
Returns
value is undefined
Call Signature
staticisType(value,type):value is null
Parameters
value
any
type
"null"
Returns
value is null
Call Signature
staticisType(value,type):value is boolean
Parameters
value
any
type
"boolean"
Returns
value is boolean
Call Signature
staticisType(value,type):value is number
Parameters
value
any
type
"number"
Returns
value is number
Call Signature
staticisType(value,type):value is object
Parameters
value
any
type
"object"
Returns
value is object
Call Signature
staticisType(value,type):value is string
Parameters
value
any
type
"string"
Returns
value is string
Call Signature
staticisType(value,type):value is any[]
Parameters
value
any
type
"Array"
Returns
value is any[]
Call Signature
staticisType(value,type):value is ArrayBuffer
Parameters
value
any
type
"ArrayBuffer"
Returns
value is ArrayBuffer
Call Signature
staticisType(value,type):value is ArrayBufferView<ArrayBufferLike>
Parameters
value
any
type
"ArrayBufferView"
Returns
value is ArrayBufferView<ArrayBufferLike>
Call Signature
staticisType<T>(value,type):value is T
Type Parameters
T
T
Parameters
value
any
type
(...args) => T
Returns
value is T
Call Signature
staticisType(value,type):boolean
Parameters
value
any
type
Returns
boolean
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
TypeError.prepareStackTrace