import { type ErrorMeta, type ErrorOptions, I18nErrorBase, setErrorMessage } from "i18n-error-base"; import type { BaseIssue } from "valibot"; export type { ErrorMeta, ErrorOptions }; export { setErrorMessage }; /** * このパッケージにおけるエラークラスの基底です。 * * @example * ``` * import { ErrorBase } from "@z-rack/core"; * * class MyError extends ErrorBase<{ readonly code: number }> {} * ``` */ export declare class ErrorBase extends I18nErrorBase { } /** * 不正な使用方法を示すエラークラスの基底です。 * * @example * ``` * import { InvalidUsageErrorBase } from "@z-rack/core"; * * class MyUsageError extends InvalidUsageErrorBase<{ readonly detail: string }> {} * ``` */ export declare class InvalidUsageErrorBase extends ErrorBase { } /** * Valibot のバリデーション問題です。 * * この型は `BaseIssue` のエイリアスであり、パッケージ内で統一して使用するために定義されています。 */ export type Issue = BaseIssue; /** * `InvalidInputError` のメタデータです。 */ export type InvalidInputErrorMeta = { /** バリデーションに失敗した入力値です。 */ readonly input: unknown; /** 発生したバリデーション問題の一覧です。少なくとも 1 つの問題を含みます。 */ readonly issues: readonly [Issue, ...Issue[]]; }; /** * `InvalidInputError` のコンストラクター引数です。 */ export type InvalidInputErrorArgs = ErrorOptions & { /** バリデーションに失敗した値です。 */ readonly value: unknown; /** 発生したバリデーション問題の一覧です。少なくとも 1 つの問題を含みます。 */ readonly issues: readonly [Issue, ...Issue[]]; }; /** * 入力値がバリデーションに失敗したことを示すエラーです。 * * @example * ``` * import { InvalidInputError } from "@z-rack/core"; * * throw new InvalidInputError({ * value: 123, * issues: [{ message: "expected string, received number" }] as any, * }); * ``` */ export declare class InvalidInputError extends InvalidUsageErrorBase { constructor(args: InvalidInputErrorArgs); } /** * `InvalidOutputError` のメタデータです。 */ export type InvalidOutputErrorMeta = { /** バリデーションに失敗した出力値です。 */ readonly output: unknown; /** 発生したバリデーション問題の一覧です。少なくとも 1 つの問題を含みます。 */ readonly issues: readonly [Issue, ...Issue[]]; }; /** * `InvalidOutputError` のコンストラクター引数です。 */ export type InvalidOutputErrorArgs = ErrorOptions & { /** バリデーションに失敗した値です。 */ readonly value: unknown; /** 発生したバリデーション問題の一覧です。少なくとも 1 つの問題を含みます。 */ readonly issues: readonly [Issue, ...Issue[]]; }; /** * 出力値がバリデーションに失敗したことを示すエラーです。 * * @example * ``` * import { InvalidOutputError } from "@z-rack/core"; * * throw new InvalidOutputError({ * value: "invalid data", * issues: [{ message: "expected valid output" }] as any, * }); * ``` */ export declare class InvalidOutputError extends InvalidUsageErrorBase { constructor(args: InvalidOutputErrorArgs); } /** * `InvalidInputTypeError` のメタデータです。 */ export type InvalidInputTypeErrorMeta = { /** 型検証に失敗した入力値です。 */ readonly input: unknown; /** 入力値の実際の型名です。 */ readonly inputType: string; /** 期待されていた型名です。 */ readonly expectedType: string; }; /** * `InvalidInputTypeError` のコンストラクター引数です。 */ export type InvalidInputTypeErrorArgs = ErrorOptions & { /** 型検証に失敗した値です。 */ readonly input: unknown; /** 入力値の実際の型名です。省略時は自動判定されます。 */ readonly inputType?: string | undefined; /** 期待されていた型名です。 */ readonly expectedType: string; }; /** * 入力値の型が期待される型と異なることを示すエラーです。 * * @example * ``` * import { InvalidInputTypeError } from "@z-rack/core"; * * throw new InvalidInputTypeError({ * input: 42, * expectedType: "string", * }); * ``` */ export declare class InvalidInputTypeError extends InvalidUsageErrorBase { constructor(args: InvalidInputTypeErrorArgs); } /** * `HttpResponseError` のコンストラクター引数です。 */ export type HttpResponseErrorArgs = ErrorOptions & { /** 異常終了した HTTP レスポンスです。 */ readonly response: Response; }; /** * HTTP レスポンスが異常終了したことを示すエラーです。 * * @example * ``` * import { HttpResponseError } from "@z-rack/core"; * * const response = new Response(null, { status: 404, statusText: "Not Found" }); * throw new HttpResponseError(response); * // => ZRackHttpResponseError: [404] Not Found * ``` */ export declare class HttpResponseError extends ErrorBase { constructor(args: HttpResponseErrorArgs); } /** * 予期しないエラーを示すエラークラスの基底です。 * * @example * ``` * import { UnexpectedErrorBase } from "@z-rack/core"; * * class MyUnexpectedError extends UnexpectedErrorBase<{ readonly detail: string }> {} * ``` */ export declare class UnexpectedErrorBase extends ErrorBase { } /** * `UnreachableError` のメタデータです。 */ export type UnreachableErrorMeta = { /** 到達不可能なコードパスに渡された値です。デバッグのために使用されます。 */ readonly value?: unknown; }; /** * `UnreachableError` のコンストラクター引数です。 */ export type UnreachableErrorArgs = ErrorOptions & UnreachableErrorMeta; /** * 到達不可能なコードパスに到達したことを示すエラーです。 * * @example * ``` * import { UnreachableError } from "@z-rack/core"; * * function assertNever(x: never): never { * throw new UnreachableError({ value: x }); * } * ``` */ export declare class UnreachableError extends UnexpectedErrorBase { constructor(args?: UnreachableErrorArgs); } /** * `UnexpectedError` のメタデータです。 */ export type UnexpectedErrorMeta = { /** 予期しない出力値です。 */ readonly output: unknown; /** 発生したバリデーション問題の一覧です。少なくとも 1 つの問題を含みます。 */ readonly issues: readonly [Issue, ...Issue[]]; }; /** * `UnexpectedError` のコンストラクター引数です。 */ export type UnexpectedErrorArgs = ErrorOptions & { /** 予期しない値です。 */ readonly value: unknown; /** 発生したバリデーション問題の一覧です。少なくとも 1 つの問題を含みます。 */ readonly issues: readonly [Issue, ...Issue[]]; }; /** * 予期しない出力値が発生したことを示すエラーです。 */ export declare class UnexpectedError extends UnexpectedErrorBase { constructor(args: UnexpectedErrorArgs); } //# sourceMappingURL=errors.d.ts.map