ServerError class

當伺服器程式碼出現錯誤時會拋出錯誤,例如無法使用。

Extends

屬性

errorNo

伺服器錯誤編號;

status

http 狀態號碼;

繼承的屬性

correlationId

與錯誤相關的 CorrelationId(關聯性)

errorCode

短字串表示誤差

errorMessage

誤差的詳細描述

message
name
platformBrokerError

當 broker 啟用時,MsalNodeRuntime 會發出 Default PlatformBrokerError

stack
stackTraceLimit

Error.stackTraceLimit 性質指定堆疊追蹤所收集的堆疊幀數(無論是由 new Error().stackError.captureStackTrace(obj)產生)。

預設值為 10 但可設定為任何有效的 JavaScript 編號。 變更會影響 值變更後 擷取的任何堆疊追蹤。

若設定為非數字值或負數值,堆疊追蹤將無法捕捉任何影格。

subError

描述錯誤的子類

繼承的方法

captureStackTrace(object, Function)

在 上.stack建立targetObject一個屬性,存取時會回傳一個字串,代表被呼叫的程式碼Error.captureStackTrace()中位置。

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

軌跡的第一行將以 作為前綴 ${myObject.name}: ${myObject.message}

可選 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

setCorrelationId(string)

建構函式詳細資料

ServerError(string, string, string, string, number)

new ServerError(errorCode?: string, errorMessage?: string, subError?: string, errorNo?: string, status?: number)

參數

errorCode

string

errorMessage

string

subError

string

errorNo

string

status

number

屬性詳細資料

errorNo

伺服器錯誤編號;

errorNo?: string

屬性值

string

status

http 狀態號碼;

status?: number

屬性值

number

繼承的屬性詳細資料

correlationId

與錯誤相關的 CorrelationId(關聯性)

correlationId: string

屬性值

string

繼承自AuthError.correlationId

errorCode

短字串表示誤差

errorCode: string

屬性值

string

繼承自AuthError.errorCode

errorMessage

誤差的詳細描述

errorMessage: string

屬性值

string

繼承自AuthError.errorMessage

message

message: string

屬性值

string

繼承自AuthError.message

name

name: string

屬性值

string

繼承自AuthError.name

platformBrokerError

當 broker 啟用時,MsalNodeRuntime 會發出 Default PlatformBrokerError

platformBrokerError?: PlatformBrokerError

屬性值

繼承自AuthError.platformBrokerError

stack

stack?: string

屬性值

string

繼承自AuthError.stack

stackTraceLimit

Error.stackTraceLimit 性質指定堆疊追蹤所收集的堆疊幀數(無論是由 new Error().stackError.captureStackTrace(obj)產生)。

預設值為 10 但可設定為任何有效的 JavaScript 編號。 變更會影響 值變更後 擷取的任何堆疊追蹤。

若設定為非數字值或負數值,堆疊追蹤將無法捕捉任何影格。

static stackTraceLimit: number

屬性值

number

繼承自AuthError.stackTraceLimit

subError

描述錯誤的子類

subError: string

屬性值

string

繼承自AuthError.subError

繼承的方法的詳細資料

captureStackTrace(object, Function)

在 上.stack建立targetObject一個屬性,存取時會回傳一個字串,代表被呼叫的程式碼Error.captureStackTrace()中位置。

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

軌跡的第一行將以 作為前綴 ${myObject.name}: ${myObject.message}

可選 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

繼承自AuthError.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

繼承自AuthError.prepareStackTrace

setCorrelationId(string)

function setCorrelationId(correlationId: string)

參數

correlationId

string

繼承自AuthError.setCorrelationId