athena_rs 3.22.1

Hyper performant polyglot Database driver
Documentation
//! Schema catalog-route error mapping helpers.
//!
//! This module centralizes translation of `sqlx` failures into stable HTTP
//! responses for schema catalog routes.

use actix_web::HttpResponse;
use sqlx::Error as SqlxError;

use crate::api::response::{internal_error, processed_error};
use crate::error::sqlx_parser::process_sqlx_error_with_context;

/// Maps schema-query failures into processed API error responses.
pub(super) fn schema_processed_query_error(err: &SqlxError, context: Option<&str>) -> HttpResponse {
    let processed = process_sqlx_error_with_context(err, context);
    processed_error(processed)
}

/// Builds a standardized 500 error response for schema fetch operations.
pub(super) fn schema_internal_fetch_error(operation: &str, err: &SqlxError) -> HttpResponse {
    internal_error(
        format!("Failed to fetch {operation}"),
        format!("Failed to fetch {operation}: {err}"),
    )
}