canonicalError (src/errors.ts)

Zero-router · packages/canonical/src/errors.ts · typescript · Apache-2.0
auth, Auth / Identity

Creates and handles canonical errors with standardized types and retry logic.

// Source: https://github.com/mhrsdev/Zero-router | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from "zod";

export const errorTypeSchema = z.enum([
  "invalid_request",
  "authentication",
  "permission",
  "not_found",
  "rate_limit",
  "quota_exceeded",
  "context_length_exceeded",
  "content_filter",
  "provider_overloaded",
  "provider_error",
  "timeout",
  "cancelled",
  "budget_exceeded",
  "no_capable_model",
  "all_providers_failed",
  "internal",
]);
export type ErrorType = z.infer<typeof errorTypeSchema>;

export const canonicalErrorSchema: z.ZodType<CanonicalError> = z.lazy(() =>
  z.object({
    type: errorTypeSchema,
    message: z.string(),
    provi

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key