@codesoul-co/hypha-core / modules/artifact/manager-error
模块用法
用于规范化、分类或暴露错误契约。Manager error 模块公开 1 类、5 函数。
从包入口导入
ts
import {
ArtifactManagerError,
artifactManagerError,
normalizedArtifactErrorCode,
validateArtifactManagerInput,
validateArtifactRepositoryOutput,
validateArtifactStoreOutput,
} from '@codesoul-co/hypha-core';使用要点
- 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
- 5 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。
公共导出
| Symbol | 种类 | 签名 | 说明 |
|---|---|---|---|
ArtifactManagerError | 类 | new ArtifactManagerError(normalizedError: NormalizedArtifactError): ArtifactManagerError | Artifact Manager Error 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。 |
artifactManagerError | 函数 | artifactManagerError(code: NormalizedArtifactError["code"], message: string, retryable?: boolean, details?: Record<string, unknown>): ArtifactManagerError | Artifact Manager Error 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
normalizedArtifactErrorCode | 函数 | normalizedArtifactErrorCode(error: unknown): NormalizedArtifactError["code"] | undefined | Normalized Artifact Error Code 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
validateArtifactManagerInput | 函数 | validateArtifactManagerInput<T>(validate: () => T): T | Validate Artifact Manager Input 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
validateArtifactRepositoryOutput | 函数 | validateArtifactRepositoryOutput<T>(validate: () => T): T | Validate Artifact Repository Output 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
validateArtifactStoreOutput | 函数 | validateArtifactStoreOutput<T>(validate: () => T): T | Validate Artifact Store Output 函数,提供 1 个公开调用签名;参数与返回类型见下表。 |
ArtifactManagerError
Artifact Manager Error 类,共公开 9 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { ArtifactManagerError } from '@codesoul-co/hypha-core'; - 源码模块:
modules/artifact/manager-error
声明
text
export declare class ArtifactManagerError extends Error {
readonly normalizedError: NormalizedArtifactError;
constructor(normalizedError: NormalizedArtifactError);
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
cause | 属性 | cause?: unknown | 公开属性;类型、只读和可选状态以签名列为准。 |
constructor | 构造函数 | (normalizedError: NormalizedArtifactError): ArtifactManagerError | 创建该类的实例。 |
message | 属性 | message: string | 公开属性;类型、只读和可选状态以签名列为准。 |
name | 属性 | name: string | 公开属性;类型、只读和可选状态以签名列为准。 |
normalizedError | 属性 | readonly normalizedError: NormalizedArtifactError | 公开属性;类型、只读和可选状态以签名列为准。 |
stack | 属性 | stack?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
static captureStackTrace | 方法 | static captureStackTrace(targetObject: object, constructorOpt?: Function): void | Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. js 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: js 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 prepareStackTrace | 方法 | static prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any | 公开方法;参数与返回类型以签名列为准。 |
static stackTraceLimit | 属性 | static 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. |
artifactManagerError
Artifact Manager Error 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { artifactManagerError } from '@codesoul-co/hypha-core'; - 源码模块:
modules/artifact/manager-error
声明
text
export declare function artifactManagerError(code: NormalizedArtifactError['code'], message: string, retryable?: boolean, details?: Record<string, unknown>): ArtifactManagerError;调用签名
text
artifactManagerError(code: NormalizedArtifactError["code"], message: string, retryable?: boolean, details?: Record<string, unknown>): ArtifactManagerError参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
code | "ARTIFACT_INVALID_INPUT" | "ARTIFACT_NOT_FOUND" | "ARTIFACT_PERMISSION_DENIED" | "ARTIFACT_TOO_LARGE" | "ARTIFACT_TYPE_DENIED" | "ARTIFACT_HASH_MISMATCH" | "ARTIFACT_VERSION_CONFLICT" | "ARTIFACT_STORE_UNAVAILABLE" | "ARTIFACT_UPLOAD_FAILED" | "ARTIFACT_DOWNLOAD_FAILED" | "ARTIFACT_DELETE_BLOCKED" | "ARTIFACT_DELETE_PARTIAL" | "ARTIFACT_VALIDATION_FAILED" | "ARTIFACT_INTERNAL_ERROR" | 是 | 必需参数;接受的值由类型列定义。 |
message | string | 是 | 必需参数;接受的值由类型列定义。 |
retryable | boolean | 否 | 可选参数;接受的值由类型列定义。 |
details | Record<string, unknown> | 否 | 可选参数;接受的值由类型列定义。 |
返回值
- 类型:
ArtifactManagerError - 说明: 返回值契约由上述类型定义。
normalizedArtifactErrorCode
Normalized Artifact Error Code 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { normalizedArtifactErrorCode } from '@codesoul-co/hypha-core'; - 源码模块:
modules/artifact/manager-error
声明
text
export declare function normalizedArtifactErrorCode(error: unknown): NormalizedArtifactError['code'] | undefined;调用签名
text
normalizedArtifactErrorCode(error: unknown): NormalizedArtifactError["code"] | undefined参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
error | unknown | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
"ARTIFACT_INVALID_INPUT" | "ARTIFACT_NOT_FOUND" | "ARTIFACT_PERMISSION_DENIED" | "ARTIFACT_TOO_LARGE" | "ARTIFACT_TYPE_DENIED" | "ARTIFACT_HASH_MISMATCH" | "ARTIFACT_VERSION_CONFLICT" | "ARTIFACT_STORE_UNAVAILABLE" | "ARTIFACT_UPLOAD_FAILED" | "ARTIFACT_DOWNLOAD_FAILED" | "ARTIFACT_DELETE_BLOCKED" | "ARTIFACT_DELETE_PARTIAL" | "ARTIFACT_VALIDATION_FAILED" | "ARTIFACT_INTERNAL_ERROR" - 说明: 返回值契约由上述类型定义。
validateArtifactManagerInput
Validate Artifact Manager Input 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { validateArtifactManagerInput } from '@codesoul-co/hypha-core'; - 源码模块:
modules/artifact/manager-error
声明
text
export declare function validateArtifactManagerInput<T>(validate: () => T): T;调用签名
text
validateArtifactManagerInput<T>(validate: () => T): T参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
validate | () => T | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
T - 说明: 返回值契约由上述类型定义。
validateArtifactRepositoryOutput
Validate Artifact Repository Output 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { validateArtifactRepositoryOutput } from '@codesoul-co/hypha-core'; - 源码模块:
modules/artifact/manager-error
声明
text
export declare function validateArtifactRepositoryOutput<T>(validate: () => T): T;调用签名
text
validateArtifactRepositoryOutput<T>(validate: () => T): T参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
validate | () => T | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
T - 说明: 返回值契约由上述类型定义。
validateArtifactStoreOutput
Validate Artifact Store Output 函数,提供 1 个公开调用签名;参数与返回类型见下表。
- 种类: 函数
- 导入:
import { validateArtifactStoreOutput } from '@codesoul-co/hypha-core'; - 源码模块:
modules/artifact/manager-error
声明
text
export declare function validateArtifactStoreOutput<T>(validate: () => T): T;调用签名
text
validateArtifactStoreOutput<T>(validate: () => T): T参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
validate | () => T | 是 | 必需参数;接受的值由类型列定义。 |
返回值
- 类型:
T - 说明: 返回值契约由上述类型定义。
