@heybox/hb-sdk API Reference - v0.9.5
    正在准备搜索索引...

    类 HbMiniProgramNetworkError<T>

    SDK 对外抛出的 HTTP 错误类型。

    仅在请求已经成功走完 bridge / runtime / 宿主调用链、但最终 HTTP 状态不满足 validateStatus 时抛出。它不表示握手失败或 bridge 级错误。网络请求没有收到 可判定的 HTTP 响应时,SDK 会抛出 HbMiniProgramSDKError 或原始 transport 错误, 不应把本类当作网络不可达的统一错误类型。

    类型参数

    • T = unknown

      标准化响应数据的类型。

    层级

    • Error
      • HbMiniProgramNetworkError
    索引

    构造函数

    属性

    cause?: unknown

    SDK 公共请求配置快照;可能含原始 URL、请求头或请求数据,记录日志前必须自行脱敏。

    data: T

    标准化响应数据;类型由 network.request<T>() 的泛型参数决定。

    headers: Record<string, string>

    标准化响应头;敏感响应头会在进入错误对象前被脱敏或移除。

    message: string
    name: string

    完整标准化响应,包含状态、头、数据和请求配置。

    stack?: string
    status: number

    HTTP 状态码;由 validateStatus 判定为失败的响应状态。

    stackTraceLimit: number

    The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

    The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

    If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

    方法

    • Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

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

      The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

      The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

      The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

      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();

      参数

      • targetObject: object
      • 可选constructorOpt: Function

      返回 void

    • Indicates whether the argument provided is a built-in Error instance or not.

      参数

      • error: unknown

      返回 error is Error