import type { SchemaBase } from './dsl.js'; import type { ImportBase } from './import-base.js'; // Exception declarations (logic-flatten-spec §5.3): each method declares the // exceptions it throws, with retryability. The runtime class is referenced by // import location — never loaded by the DSL. /** Describes an exception a method can throw. */ export interface ExceptionSchema extends SchemaBase, Omit { type: 'exception'; } export function defineException(options: { name: string; from: string; description?: string; }): ExceptionSchema { return { type: 'exception', name: options.name, from: options.from, description: options.description, }; } /** Timeout or unrecoverable I/O failure */ export const IOException = defineException({ name: 'IOException', from: '@pylonts/core', description: 'Network timeout or unrecoverable error', }); /** Business error code carried by the exception*/ export const CodeException = defineException({ name: 'CodeException', from: '@pylonts/core', description: 'Business error code', }); /** Business rule violation (maps to 422) */ export const BusinessException = defineException({ name: 'BusinessException', from: '@pylonts/core', description: 'Business rule violation', }); /** Anything else — unexpected, carries no business semantics. Rendered as a * plain Error / system exception, no dedicated runtime class. */ export const UnexpectedException = defineException({ name: 'UnexpectedException', from: '', description: 'Unexpected error', });