你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。

AuthenticationError class

提供关于Azure Active Directory认证失败的详细信息。 errorResponse 字段包含有关特定失败的更多详细信息。

扩展

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