Skip to main content
Glama

microsandbox

by microsandbox
error.rs2.38 kB
//! Error handling for microsandbox portal. use axum::{ http::StatusCode, response::{IntoResponse, Response}, Json, }; use thiserror::Error; use crate::payload::JsonRpcError; //-------------------------------------------------------------------------------------------------- // Types //-------------------------------------------------------------------------------------------------- /// Main error type for microsandbox portal #[derive(Debug, Error)] pub enum PortalError { /// Error related to JSON-RPC protocol #[error("JSON-RPC error: {0}")] JsonRpc(String), /// Method not found #[error("Method not found: {0}")] MethodNotFound(String), /// Internal server error #[error("Internal server error: {0}")] Internal(String), /// Error during parsing #[error("Parse error: {0}")] Parse(String), } //-------------------------------------------------------------------------------------------------- // Trait Implementations //-------------------------------------------------------------------------------------------------- impl IntoResponse for PortalError { fn into_response(self) -> Response { let (status, error_response) = match self { PortalError::JsonRpc(message) => { let error = JsonRpcError { code: -32600, message, data: None, }; (StatusCode::BAD_REQUEST, error) } PortalError::MethodNotFound(message) => { let error = JsonRpcError { code: -32601, message, data: None, }; (StatusCode::NOT_FOUND, error) } PortalError::Parse(message) => { let error = JsonRpcError { code: -32700, message, data: None, }; (StatusCode::BAD_REQUEST, error) } PortalError::Internal(message) => { let error = JsonRpcError { code: -32603, message, data: None, }; (StatusCode::INTERNAL_SERVER_ERROR, error) } }; (status, Json(error_response)).into_response() } }

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/microsandbox/microsandbox'

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