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.】