共用方式為


MessagingError class

描述傳訊錯誤的基類。

Extends

Error

建構函式

MessagingError(string, Error)

屬性

address

網路連線失敗的位址。 只有當 MessagingError 是以 Node.js SystemError具現化時,才會存在。

code

識別錯誤的字串標籤。

errno

系統提供的錯誤號碼。 只有當 MessagingError 是以 Node.js SystemError具現化時,才會存在。

info

有關錯誤的額外詳細數據。

name

錯誤名稱。 默認值:「MessagingError」。。

port

無法使用的網路連線埠。 只有當 MessagingError 是以 Node.js SystemError具現化時,才會存在。

retryable

描述錯誤是否可重試。 默認值:true。

syscall

觸發錯誤之系統呼叫的名稱。 只有當 MessagingError 是以 Node.js SystemError具現化時,才會存在。

繼承的屬性

message
stack
stackTraceLimit

Error.stackTraceLimit 屬性指定堆疊跟蹤收集的堆疊幀數(無論是由 new Error().stack 還是 Error.captureStackTrace(obj)生成)。

默認值為 10 but can be set to any valid JavaScript number. 更改將影響在更改值 捕獲的任何堆疊跟蹤。

如果設置為非數位值或設置為負數,則堆疊跟蹤將不會捕獲任何幀。

繼承的方法

captureStackTrace(object, Function)

在上創建一個 .stack 屬性,該屬性在訪問時返回一個字串,該字串 targetObject表示調用的代碼 Error.captureStackTrace() 中的位置。

const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

跟蹤的第一行將以 為 ${myObject.name}: ${myObject.message}前綴。

optional constructorOpt 參數接受一個函數。 如果給定,則 上面的 constructorOpt所有幀 ,包括 constructorOpt,將從生成的堆疊跟蹤中省略。

constructorOpt 參數可用於向使用者隱藏錯誤生成的實現詳細資訊。 例如:

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();
prepareStackTrace(Error, CallSite[])

請參閱 https://v8.dev/docs/stack-trace-api#customizing-stack-traces

建構函式詳細資料

MessagingError(string, Error)

new MessagingError(message: string, originalError?: Error)

參數

message

string

提供錯誤詳細信息的錯誤訊息。

originalError

Error

如果屬性符合在 Node.js SystemError上找到的屬性,其屬性將會複製到 MessagingError 的錯誤。

屬性詳細資料

address

網路連線失敗的位址。 只有當 MessagingError 是以 Node.js SystemError具現化時,才會存在。

address?: string

屬性值

string

code

識別錯誤的字串標籤。

code?: string

屬性值

string

errno

系統提供的錯誤號碼。 只有當 MessagingError 是以 Node.js SystemError具現化時,才會存在。

errno?: string | number

屬性值

string | number

info

有關錯誤的額外詳細數據。

info?: any

屬性值

any

name

錯誤名稱。 默認值:「MessagingError」。。

name: string

屬性值

string

port

無法使用的網路連線埠。 只有當 MessagingError 是以 Node.js SystemError具現化時,才會存在。

port?: number

屬性值

number

retryable

描述錯誤是否可重試。 默認值:true。

retryable: boolean

屬性值

boolean

syscall

觸發錯誤之系統呼叫的名稱。 只有當 MessagingError 是以 Node.js SystemError具現化時,才會存在。

syscall?: string

屬性值

string

繼承的屬性詳細資料

message

message: string

屬性值

string

繼承自 Error.message

stack

stack?: string

屬性值

string

繼承自 Error.stack

stackTraceLimit

Error.stackTraceLimit 屬性指定堆疊跟蹤收集的堆疊幀數(無論是由 new Error().stack 還是 Error.captureStackTrace(obj)生成)。

默認值為 10 but can be set to any valid JavaScript number. 更改將影響在更改值 捕獲的任何堆疊跟蹤。

如果設置為非數位值或設置為負數,則堆疊跟蹤將不會捕獲任何幀。

static stackTraceLimit: number

屬性值

number

繼承自 Error.stackTraceLimit

繼承的方法的詳細資料

captureStackTrace(object, Function)

在上創建一個 .stack 屬性,該屬性在訪問時返回一個字串,該字串 targetObject表示調用的代碼 Error.captureStackTrace() 中的位置。

const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`

跟蹤的第一行將以 為 ${myObject.name}: ${myObject.message}前綴。

optional constructorOpt 參數接受一個函數。 如果給定,則 上面的 constructorOpt所有幀 ,包括 constructorOpt,將從生成的堆疊跟蹤中省略。

constructorOpt 參數可用於向使用者隱藏錯誤生成的實現詳細資訊。 例如:

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();
static function captureStackTrace(targetObject: object, constructorOpt?: Function)

參數

targetObject

object

constructorOpt

Function

繼承自 Error.captureStackTrace

prepareStackTrace(Error, CallSite[])

請參閱 https://v8.dev/docs/stack-trace-api#customizing-stack-traces

static function prepareStackTrace(err: Error, stackTraces: CallSite[]): any

參數

err

Error

stackTraces

CallSite[]

傳回

any

繼承自 Error.prepareStackTrace