Skip to content
API reference

errors

Import
import * as api from "@fungi.computer/agar/errors";
Kind Export Description
class AppError The SDK’s one typed failure. Carries a closed code naming the failure kind and an explicit retryable verdict, instead of leaving callers to guess either from the message or exception shape.
type alias MediaProviderDiagnostic Declaration-safe projection of the canonical Media diagnostic grammar.
type alias AppErrorCode One closed App error code from appErrorCodes.
type alias AppDeliveryPending One pending-delivery refusal shared by admission and the shell.
type alias AppErrorOptions Required construction options for an AppError.
type alias ErrorCopy Trusted presentation copy; overrides never change recovery or retry policy.
type alias ErrorDescription Recovery hints are for the caller’s UI, never an instruction to retry automatically.
constant mediaProviderDiagnosticWireSchema Documentable wire projection of the canonical diagnostic grammar. Maintained converters preserve its closed objects and numeric bounds; decoding still returns the declaration-safe public diagnostic type.
constant appErrorCodes The closed set of reasons an AppError can state; every SDK and host-reported failure is tagged with exactly one of these codes.
function decodeMediaProviderDiagnostic() Decode only safe provider facts, rejecting unmodeled private fields.
function decodeMediaProviderErrorCategory() Decode an ordinary Error name without retaining arbitrary upstream text.
function describeAppError() Describe an SDK-decoded failure without exposing exception or request data. The error owner retains retry truth. Grant and reconnect hints describe prerequisites, so they can accompany a non-retryable operation.

The SDK’s one typed failure. Carries a closed code naming the failure kind and an explicit retryable verdict, instead of leaving callers to guess either from the message or exception shape.

  • Error
Signature
new AppError(message, options): AppError;
Parameter Type
message string
options AppErrorOptions

AppError

Signature
Error.constructor;
Signature
readonly code:
| "CANCELLED"
| "CAPABILITY_DENIED"
| "CAPABILITY_REVOKED"
| "COMMAND_NOT_DECLARED"
| "CONFLICT"
| "DELIVERY_PENDING"
| "DISCONNECTED"
| "FILE_TOO_LARGE"
| "HOST_FAILURE"
| "IDENTITY"
| "INSUFFICIENT_CREDIT"
| "INVALID_ARGUMENT"
| "PROTOCOL"
| "SAFETY_FILTER_REFUSED"
| "SELECTION_CHANGED"
| "TIMEOUT";
Signature
readonly retryable: boolean;

MediaProviderDiagnostictype alias

Section titled “MediaProviderDiagnostic”
Signature
type MediaProviderDiagnostic =
| Readonly<{
category:
| "InferenceUpstreamError"
| "AiInternalError"
| "TypeError"
| "AbortError"
| "TimeoutError"
| "Error";
code: number | null;
}>
| Readonly<{
category: "result_download";
status: number;
}>;

Declaration-safe projection of the canonical Media diagnostic grammar.


AppErrorCodetype alias

Section titled “AppErrorCode”
Signature
type AppErrorCode = (typeof appErrorCodes)[number];

One closed App error code from appErrorCodes.


AppDeliveryPendingtype alias

Section titled “AppDeliveryPending”
Signature
type AppDeliveryPending = Readonly<{
code: Extract<AppErrorCode, "DELIVERY_PENDING">;
}>;

One pending-delivery refusal shared by admission and the shell.


AppErrorOptionstype alias

Section titled “AppErrorOptions”
Signature
type AppErrorOptions = object;

Required construction options for an AppError.

Signature
readonly optional cause?: unknown;
Signature
readonly code: AppErrorCode;
Signature
readonly retryable: boolean;

Every error states retry truth explicitly; absence is not a verdict.


ErrorCopytype alias

Section titled “ErrorCopy”
Signature
type ErrorCopy = Readonly<{
title: string;
message: string;
}>;

Trusted presentation copy; overrides never change recovery or retry policy.


ErrorDescriptiontype alias

Section titled “ErrorDescription”
Signature
type ErrorDescription = ErrorCopy &
Readonly<{
retryable: boolean;
action?: "grant" | "retry" | "reconnect" | "billing";
}>;

Recovery hints are for the caller’s UI, never an instruction to retry automatically.

mediaProviderDiagnosticWireSchemaconstant

Section titled “mediaProviderDiagnosticWireSchema”
Signature
const mediaProviderDiagnosticWireSchema: ZodPipe<
ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>,
ZodTransform<
| Readonly<{
category:
| "InferenceUpstreamError"
| "AiInternalError"
| "TypeError"
| "AbortError"
| "TimeoutError"
| "Error";
code: number | null;
}>
| Readonly<{
category: "result_download";
status: number;
}>,
unknown
>
>;

Documentable wire projection of the canonical diagnostic grammar. Maintained converters preserve its closed objects and numeric bounds; decoding still returns the declaration-safe public diagnostic type.


appErrorCodesconstant

Section titled “appErrorCodes”
Signature
const appErrorCodes: readonly [
"CANCELLED",
"CAPABILITY_DENIED",
"CAPABILITY_REVOKED",
"COMMAND_NOT_DECLARED",
"CONFLICT",
"DELIVERY_PENDING",
"DISCONNECTED",
"FILE_TOO_LARGE",
"HOST_FAILURE",
"IDENTITY",
"INSUFFICIENT_CREDIT",
"INVALID_ARGUMENT",
"PROTOCOL",
"SAFETY_FILTER_REFUSED",
"SELECTION_CHANGED",
"TIMEOUT",
];

The closed set of reasons an AppError can state; every SDK and host-reported failure is tagged with exactly one of these codes.

decodeMediaProviderDiagnostic()function

Section titled “decodeMediaProviderDiagnostic()”
Signature
function decodeMediaProviderDiagnostic(input): MediaProviderDiagnostic;

Decode only safe provider facts, rejecting unmodeled private fields.

Parameter Type
input unknown

MediaProviderDiagnostic


decodeMediaProviderErrorCategory()function

Section titled “decodeMediaProviderErrorCategory()”
Signature
function decodeMediaProviderErrorCategory(
input,
):
| "InferenceUpstreamError"
| "AiInternalError"
| "TypeError"
| "AbortError"
| "TimeoutError"
| "Error";

Decode an ordinary Error name without retaining arbitrary upstream text.

Parameter Type
input string | undefined

| "InferenceUpstreamError" | "AiInternalError" | "TypeError" | "AbortError" | "TimeoutError" | "Error"


describeAppError()function

Section titled “describeAppError()”
Signature
function describeAppError(cause, overrides?): ErrorDescription;

Describe an SDK-decoded failure without exposing exception or request data. The error owner retains retry truth. Grant and reconnect hints describe prerequisites, so they can accompany a non-retryable operation.

Parameter Type
cause unknown
overrides? Partial<Record< | "CANCELLED" | "CAPABILITY_DENIED" | "CAPABILITY_REVOKED" | "COMMAND_NOT_DECLARED" | "CONFLICT" | "DELIVERY_PENDING" | "DISCONNECTED" | "FILE_TOO_LARGE" | "HOST_FAILURE" | "IDENTITY" | "INSUFFICIENT_CREDIT" | "INVALID_ARGUMENT" | "PROTOCOL" | "SAFETY_FILTER_REFUSED" | "SELECTION_CHANGED" | "TIMEOUT", Readonly<{ title: string; message: string; }>>>

ErrorDescription