mcp-crawl4ai-ts
Version:
TypeScript MCP server for Crawl4AI - web crawling and content extraction
30 lines • 969 B
JavaScript
export class BaseHandler {
service;
axiosClient;
sessions;
constructor(service, axiosClient, sessions) {
this.service = service;
this.axiosClient = axiosClient;
this.sessions = sessions;
}
formatError(error, operation) {
const errorWithResponse = error;
let errorMessage = '';
const data = errorWithResponse.response?.data;
if (typeof data === 'object' && data && 'detail' in data) {
errorMessage = data.detail;
}
else if (data) {
// If data is an object, stringify it
errorMessage = typeof data === 'object' ? JSON.stringify(data) : String(data);
}
else if (error instanceof Error) {
errorMessage = error.message;
}
else {
errorMessage = String(error);
}
return new Error(`Failed to ${operation}: ${errorMessage}`);
}
}
//# sourceMappingURL=base-handler.js.map