AuthenticationError class

提供關於無法與 Azure Active Directory 認證失敗的詳細資訊。 [errorResponse] 欄位包含特定失敗的詳細數據。

Extends

Error

屬性

errorResponse

錯誤回應詳細數據。

statusCode

從驗證要求傳回的 HTTP 狀態代碼。

繼承的屬性

message
name
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

建構函式詳細資料

AuthenticationError(number, string | object | null | undefined, { cause?: unknown })

new AuthenticationError(statusCode: number, errorBody: string | object | null | undefined, options?: { cause?: unknown })

參數

statusCode

number

errorBody

string | object | null | undefined

options

{ cause?: unknown }

屬性詳細資料

errorResponse

錯誤回應詳細數據。

errorResponse: ErrorResponse

屬性值

statusCode

從驗證要求傳回的 HTTP 狀態代碼。

statusCode: number

屬性值

number

繼承的屬性詳細資料

message

message: string

屬性值

string

繼承自 Error.message

name

name: string

屬性值

string

繼承自 Error.name

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