{"version":3,"file":"provider-error.mjs","names":[],"sources":["../../../../../../../ai/src/errors/provider-error.ts"],"sourcesContent":["import { AIError, type AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\nimport type { AIErrorCode } from \"./error-code.type\";\n\n/**\n * Any failure that originated from the model provider (OpenAI, Azure,\n * OpenRouter, local gateway). Base class for the provider subclasses\n * below — raw provider errors caught in an adapter are always wrapped\n * into *some* `ProviderError` so downstream code can branch on\n * `instanceof ProviderError` when any provider-side failure will do.\n *\n * **Subclasses (more specific first).**\n * - `ProviderRateLimitError` — 429 / rate-limit / quota exhaustion.\n * - `ProviderTimeoutError` — connection or request timeout.\n * - `ContextLengthExceededError` — prompt exceeded the model window.\n * - `ContentFilterError` — response blocked by provider safety policy.\n * - `ProviderAuthError` — bad / expired API key.\n * - `InvalidRequestError` — catch-all 4xx not covered above.\n *\n * When no subclass fits (e.g. 5xx server error, unknown network\n * failure), adapters throw plain `ProviderError` with the raw payload\n * captured in `context`.\n *\n * @example\n * if (result.error instanceof ProviderError) {\n *   if (result.error instanceof ProviderRateLimitError) {\n *     return retryAfter(result.error.retryAfter ?? 1000);\n *   }\n * }\n */\nexport class ProviderError extends AIError {\n  public static readonly defaultCategory: ErrorCategory = \"provider\";\n\n  public constructor(\n    message: string,\n    options?: AIErrorOptions,\n    code: AIErrorCode = \"PROVIDER_ERROR\",\n  ) {\n    super(code, message, options);\n    this.name = \"ProviderError\";\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,gBAAb,cAAmC,QAAQ;;yBACe;;CAExD,AAAO,YACL,SACA,SACA,OAAoB,kBACpB;EACA,MAAM,MAAM,SAAS,OAAO;EAC5B,KAAK,OAAO;CACd;AACF"}