/** * Typed errors for the WayForPay client. Lets the MCP server's `fail()` helper * surface a structured response (status / transactionType / api body) instead * of an opaque string. */ export interface WfpErrorOptions { status: number; transactionType?: string; apiError?: unknown; cause?: unknown; } export class WfpError extends Error { readonly status: number; readonly transactionType: string | undefined; readonly apiError: unknown; override readonly cause: unknown; constructor(message: string, opts: WfpErrorOptions) { super(message); this.name = "WfpError"; this.status = opts.status; this.transactionType = opts.transactionType; this.apiError = opts.apiError; this.cause = opts.cause; } } /** * Distinguishes "WFP rejected the merchantSignature / secretKey" from generic * API failures so callers can prompt the user to fix credentials specifically. */ export class WfpAuthError extends WfpError { constructor(message: string, opts: WfpErrorOptions) { super(message, opts); this.name = "WfpAuthError"; } }