Skip to main content
Glama

Google Cloud MCP Server

by andyl25
error.js1.57 kB
/** * Error handling utilities */ /** * Custom error class for Google Cloud MCP server errors */ export class GcpMcpError extends Error { code; statusCode; details; constructor(message, code = 'INTERNAL_ERROR', statusCode = 500, details) { super(message); this.name = 'GcpMcpError'; this.code = code; this.statusCode = statusCode; this.details = details; } } /** * Formats an error into a consistent structure for MCP responses * * @param error The error to format * @returns A formatted error object */ export function formatError(error) { if (error instanceof GcpMcpError) { return { message: error.message, code: error.code, details: error.details }; } if (error instanceof Error) { return { message: error.message, code: 'UNKNOWN_ERROR', details: error.stack }; } return { message: String(error), code: 'UNKNOWN_ERROR' }; } /** * Safely handles errors in async functions and returns a formatted error response * * @param fn The async function to execute * @returns A function that returns either the result or a formatted error */ export function safeAsync(fn) { return async (...args) => { try { return await fn(...args); } catch (error) { console.error('Error in async operation:', error); return { error: formatError(error) }; } }; } //# sourceMappingURL=error.js.map

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/andyl25/googlecloud-mcp'

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