UNPKG

tensaikit

Version:

An autonomous DeFi AI Agent Kit on Katana enabling AI agents to plan and execute on-chain financial operations.

31 lines (30 loc) 952 B
"use strict"; /** * Custom error handler for the application */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createError = exports.handleError = exports.CustomError = void 0; class CustomError extends Error { constructor(message, code) { super(message); this.code = code; this.name = "CustomError"; } } exports.CustomError = CustomError; const handleError = (message, error) => { if (error instanceof CustomError) { return error; } if (error instanceof Error) { const fullMessage = `${message}: ${error.message}`; return new CustomError(fullMessage, "UNKNOWN_ERROR"); } const fullMessage = `${message}: ${JSON.stringify(error)}`; return new CustomError(fullMessage, "UNKNOWN_ERROR"); }; exports.handleError = handleError; const createError = (message, code) => { return new CustomError(message, code); }; exports.createError = createError;