Skip to main content
Glama
errorHandler.ts655 B
import { Request, Response, NextFunction } from 'express'; export interface AppError extends Error { statusCode?: number; isOperational?: boolean; } export const errorHandler = ( error: AppError, req: Request, res: Response, next: NextFunction ) => { const statusCode = error.statusCode || 500; const message = error.message || 'Internal Server Error'; // Log error for debugging console.error('Error:', error); // Don't leak error details in production const isDevelopment = process.env.NODE_ENV === 'development'; res.status(statusCode).json({ error: message, ...(isDevelopment && { stack: error.stack }) }); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ChiragPatankar/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server