Unified error type for media route adapters with HTTP status mapping, simplifying error handling across image, TTS, embeddings, and search.
// Source: https://github.com/quangdang46/openproxy | License: MIT | Copyright 2024-2026 decolua and contributors
// Provided via justclaw.it.com; keep this notice with the code.
//! Shared error type for media-route handlers.
//!
//! All four media-route adapters (image, tts, embeddings, search) report
//! failures through this enum so the HTTP layer has one converter.
use thiserror::Error;
#[derive(Debug, Error)]
pub enum MediaError {
#[error("validation: {0}")]
Validation(String),
#[error("HTTP {status}: {message}")]
Http { status: u16, message: String },
#[error("upstream: {0}")]
Upstream(String),
}
impl MediaError {
/// Best-fit HTTP status for this error.
pub fn status(&self) -> u16 {
match self {
MediaError::Validation(_) => 400
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key