new Error(message[, options])
创建新的 Error
对象并将 error.message
属性设置为提供的文本消息。
如果对象作为 message
传入,则通过调用 String(message)
生成文本消息。
如果提供了 cause
选项,则将其分配给 error.cause
属性。
error.stack
属性将代表代码中调用 new Error()
的点。
堆栈跟踪依赖于 V8 的堆栈跟踪 API。
堆栈跟踪仅扩展到 (a) 同步代码执行的开始,或 (b) 属性 Error.stackTraceLimit
给定的帧数,以较小者为准。
Creates a new Error
object and sets the error.message
property to the
provided text message. If an object is passed as message
, the text message
is generated by calling String(message)
. If the cause
option is provided,
it is assigned to the error.cause
property. The error.stack
property will
represent the point in the code at which new Error()
was called. Stack traces
are dependent on V8's stack trace API. Stack traces extend only to either
(a) the beginning of synchronous code execution, or (b) the number of frames
given by the property Error.stackTraceLimit
, whichever is smaller.