use std::path::PathBuf;
use omp_core::Str;
use omp_llm_gateway::local::LocalEndpoint;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum AppError {
#[error(transparent)]
Daemon(#[from] crate::daemon::DaemonError),
#[error(transparent)]
Rpc(#[from] omp_rpc::Error),
#[error(transparent)]
Status(#[from] tonic::Status),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
BrokerStore(#[from] omp_llm_broker::store::StoreError),
#[error(transparent)]
LlmTypes(#[from] omp_llm_types::Error),
#[error(transparent)]
BrokerOAuth(#[from] omp_llm_broker::oauth::OAuthError),
#[error(transparent)]
BrokerCli(#[from] omp_llm_broker::cli::CliError),
#[error(transparent)]
Catalog(#[from] omp_llm_catalog::models::CatalogError),
#[error(transparent)]
LocalInference(#[from] omp_llm_local::Error),
#[error("inference failed: {detail}")]
InferenceFailed {
detail: Str,
},
#[error("inference stream ended without a terminal outcome")]
InferenceStreamUnterminated,
#[error("local inference stream ended without a terminal outcome")]
LocalInferenceStreamUnterminated,
#[error("auth migrate requires --sqlite or --json-file")]
AuthMigrateArgsRequired,
#[error("HOME or OMP_DATA_DIR must be set")]
DataDirNotConfigured,
#[error("catalog source and destination must be different files")]
SameCatalogSourceAndDestination,
#[error("could not read {path:?}: {source}")]
ReadCatalogSource {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("could not write {path:?}: {source}")]
WriteCatalogDestination {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("could not connect to {endpoint}: {source}")]
ConnectGateway {
endpoint: LocalEndpoint,
#[source]
source: omp_rpc::Error,
},
}
pub type Result<T, E = AppError> = std::result::Result<T, E>;