type ErrorConstructor = new (...args: any[]) => Error; /** * 判断目标是否是指定的 Error * * - 无参数: 判断是否是 Error 类型 * - `string`: 精确匹配错误消息 * - `RegExp`: 正则匹配错误消息 * - `Error 构造函数`: instanceof 检查 * - `{ type: string }`: 匹配 error.type 属性 * * 消息提取顺序 (兼容 Axios / fetch 等 HTTP 库): * 1. error.response.data.error / message (Axios 后端自定义) * 2. error.response.statusText (Axios HTTP 状态文本) * 3. error.data.error / message (部分 fetch 封装库) * 4. error.statusText (部分 fetch 封装库) * 5. error.message (原生 Error) * * @example * * // `string` 目标,判断 err(message)是否是 "ErrorA" 错误 * errorOf(err, "ErrorA") * * // `RegExp` 目标, 使用正则判断 err(message)是否是 "TypeError" 开头错误 * errorOf(err, /^TypeError/) * * // `Error` 目标, 判断 err 是否是 Error 类型 * errorOf(err, TypeError) * * // `object` 目标, 判断 err.type 是否等于指定的 type * errorOf(err, { type: "CustomErrorType" }) * * */ export declare function errorOf(error: unknown): error is Error; export declare function errorOf(error: unknown, errorDefine: T): error is InstanceType; export declare function errorOf(error: unknown, errorDefine: string | RegExp | { type: string; }): boolean; export {}; //# sourceMappingURL=errorOf.d.ts.map