import { getErrorFromUnknown } from './utils.js'; import type { SerializableError, SerializedError } from './utils.js'; export { getErrorFromUnknown }; export type { SerializableError, SerializedError }; export declare enum ErrorDomain { TOOL = "TOOL", AGENT = "AGENT", MCP = "MCP", AGENT_NETWORK = "AGENT_NETWORK", MASTRA_SERVER = "MASTRA_SERVER", MASTRA_OBSERVABILITY = "MASTRA_OBSERVABILITY", MASTRA_WORKFLOW = "MASTRA_WORKFLOW", MASTRA_VOICE = "MASTRA_VOICE", MASTRA_VECTOR = "MASTRA_VECTOR", MASTRA_MEMORY = "MASTRA_MEMORY", LLM = "LLM", EVAL = "EVAL", SCORER = "SCORER", A2A = "A2A", MASTRA_INSTANCE = "MASTRA_INSTANCE", MASTRA = "MASTRA", DEPLOYER = "DEPLOYER", STORAGE = "STORAGE", MODEL_ROUTER = "MODEL_ROUTER" } export declare enum ErrorCategory { UNKNOWN = "UNKNOWN", USER = "USER", SYSTEM = "SYSTEM", THIRD_PARTY = "THIRD_PARTY" } type Scalar = null | boolean | number | string; type Json = [T] extends [Scalar | undefined] ? Scalar : [T] extends [{ [x: number]: unknown; }] ? { [K in keyof T]: Json; } : never; /** * Defines the structure for an error's metadata. * This is used to create instances of MastraError. */ export interface IErrorDefinition { /** Unique identifier for the error. */ id: Uppercase; /** * Optional custom error message that overrides the original error message. * If not provided, the original error message will be used, or 'Unknown error' if no error is provided. */ text?: string; /** * Functional domain of the error (e.g., CONFIG, BUILD, API). */ domain: DOMAIN; /** Broad category of the error (e.g., USER, SYSTEM, THIRD_PARTY). */ category: CATEGORY; details?: Record>; } /** * JSON representation of a MastraError for serialization */ export interface MastraErrorJSON { message: string; code: Uppercase; category: CATEGORY; domain: DOMAIN; details?: Record>; cause?: ReturnType; } /** * Base error class for the Mastra ecosystem. * It standardizes error reporting and can be extended for more specific error types. */ export declare class MastraBaseError extends Error { readonly id: Uppercase; readonly domain: DOMAIN; readonly category: CATEGORY; readonly details?: Record>; readonly message: string; cause?: SerializableError; constructor(errorDefinition: IErrorDefinition, originalError?: string | Error | MastraBaseError | unknown); /** * Returns a structured representation of the error, useful for logging or API responses. */ toJSONDetails(): { message: string; domain: DOMAIN; category: CATEGORY; details: Record | undefined; }; toJSON(): MastraErrorJSON; toString(): string; } export declare class MastraError extends MastraBaseError<`${ErrorDomain}`, `${ErrorCategory}`> { } //# sourceMappingURL=index.d.ts.map