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

InvocationError class

当调用失败或被取消时,会抛出错误。

扩展

Error

构造函数

InvocationError(string, InvocationErrorOptions)

属性

errorDetail

如果有,提供服务方的错误详情。

invocationId

请求的调用ID。

继承属性

message
name
stack
stackTraceLimit

Error.stackTraceLimit 性质指定了栈跟踪收集的堆栈帧数(无论是由 new Error().stackError.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

构造函数详细信息

InvocationError(string, InvocationErrorOptions)

new InvocationError(message: string, options: InvocationErrorOptions)

参数

message

string

属性详细信息

errorDetail

如果有,提供服务方的错误详情。

errorDetail?: InvokeResponseError

属性值

invocationId

请求的调用ID。

invocationId: string

属性值

string

继承属性详细信息

message

message: string

属性值

string

继承自 Error.message

name

name: string

属性值

string

继承自 Error.name 的

stack

stack?: string

属性值

string

继承自 Error.stack

stackTraceLimit

Error.stackTraceLimit 性质指定了栈跟踪收集的堆栈帧数(无论是由 new Error().stackError.captureStackTrace(obj)生成)。

默认值为 10 ,但可以设置为任意有效的JavaScript编号。 变更会影响值变更 捕获的任何栈跟踪。

如果设置为非数字值或负数值,堆栈追踪不会捕获任何帧。

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}

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

继承自 错误.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