مشاركة عبر


AuthenticationError class

يوفر تفاصيل حول فشل المصادقة باستخدام Azure Active Directory. يحتوي الحقل errorResponse على مزيد من التفاصيل حول الفشل المحدد.

يمتد

Error

المنشئون

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

الخصائص

errorResponse

تفاصيل استجابة الخطأ.

statusCode

تم إرجاع رمز حالة HTTP من طلب المصادقة.

الخصائص الموروثة

message
name
stack
stackTraceLimit

تحدد الخاصية Error.stackTraceLimit عدد إطارات المكدس التي تم تجميعها بواسطة تتبع مكدس (سواء تم إنشاؤها بواسطة new Error().stack أو Error.captureStackTrace(obj)).

القيمة الافتراضية هي 10 ولكن يمكن تعيينها إلى أي رقم JavaScript صالح. ستؤثر التغييرات على أي تتبع مكدس تم التقاطه بعد تغيير القيمة.

إذا تم تعيينها إلى قيمة غير رقمية، أو تم تعيينها على رقم سالب، فلن تلتقط تتبعات المكدس أي إطارات.

الأساليب المتوارثة

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

تفاصيل المنشئ

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

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

المعلمات

statusCode

number

errorBody

undefined | null | string | object

options

{ cause?: unknown }

تفاصيل الخاصية

errorResponse

تفاصيل استجابة الخطأ.

errorResponse: ErrorResponse

قيمة الخاصية

statusCode

تم إرجاع رمز حالة HTTP من طلب المصادقة.

statusCode: number

قيمة الخاصية

number

تفاصيل الخاصية الموروثة

message

message: string

قيمة الخاصية

string

موروثة من خطأ.message

name

name: string

قيمة الخاصية

string

موروث من Error.name

stack

stack?: string

قيمة الخاصية

string

موروث من Error.stack

stackTraceLimit

تحدد الخاصية Error.stackTraceLimit عدد إطارات المكدس التي تم تجميعها بواسطة تتبع مكدس (سواء تم إنشاؤها بواسطة new Error().stack أو Error.captureStackTrace(obj)).

القيمة الافتراضية هي 10 ولكن يمكن تعيينها إلى أي رقم JavaScript صالح. ستؤثر التغييرات على أي تتبع مكدس تم التقاطه بعد تغيير القيمة.

إذا تم تعيينها إلى قيمة غير رقمية، أو تم تعيينها على رقم سالب، فلن تلتقط تتبعات المكدس أي إطارات.

static stackTraceLimit: number

قيمة الخاصية

number

موروث من خطأ.stackTraceLimit

تفاصيل الأساليب المتوارثة

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

موروث من 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

موروث من خطأ.prepareStackTrace