Skip to main content
Glama
async_route.rs961 B
use dal::{ DalContext, WsEvent, }; use hyper::Uri; use telemetry::prelude::*; pub type TaskId = ulid::Ulid; /// Handler for any fatal error condition in an "async" SDF route (one that does /// work on a background thread and returns the result via a WsEvent) pub async fn handle_error( ctx: &DalContext, uri: Uri, task_id: TaskId, err: impl std::error::Error, ) { let err_string = err.to_string(); error!("async route '{}' error: {}", uri.to_string(), err_string); match WsEvent::async_error(ctx, task_id, err_string).await { Ok(event) => { if let Err(commit_err) = event.publish_immediately(ctx).await { error!(si.error.message = ?commit_err.to_string(), "Unable to publish ws event for async error"); } } Err(creation_err) => { error!(si.error.message = ?creation_err.to_string(), "Unable to create ws event for async error"); } } }

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/systeminit/si'

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