use meerkat_core::SessionId;
use meerkat_core::SurfaceSessionRecoveryError;
use meerkat_core::service::SessionError;
#[derive(Debug, thiserror::Error)]
pub enum LiveOpenPrecheckError {
#[error("failed to resolve live session {session_id}: {source}")]
SessionLookup {
session_id: SessionId,
#[source]
source: SessionError,
},
#[error("model {model} (provider {provider}) does not support realtime")]
ModelNotRealtime {
model: String,
provider: &'static str,
},
#[error("provider {provider} has no live adapter wired in this build")]
ProviderHasNoLiveAdapter {
provider: &'static str,
},
}
#[derive(Debug, thiserror::Error)]
pub enum RecoveryError {
#[error(transparent)]
Recovery(#[from] SurfaceSessionRecoveryError),
#[error("failed to prepare runtime bindings for session {session_id}: {message}")]
BindingPreparation {
session_id: SessionId,
message: String,
},
#[error(transparent)]
Session(#[from] SessionError),
}
impl RecoveryError {
#[must_use]
pub const fn code(&self) -> &'static str {
match self {
Self::Recovery(SurfaceSessionRecoveryError::InvalidOverride(_)) => "INVALID_OVERRIDE",
Self::Recovery(SurfaceSessionRecoveryError::MissingSessionMetadata(_)) => {
"MISSING_SESSION_METADATA"
}
Self::Recovery(SurfaceSessionRecoveryError::MissingRuntimeBuildMode(_)) => {
"MISSING_RUNTIME_BUILD_MODE"
}
Self::BindingPreparation { .. } => "BINDING_PREPARATION",
Self::Session(_) => "SESSION",
}
}
}
impl LiveOpenPrecheckError {
#[must_use]
pub const fn code(&self) -> &'static str {
match self {
Self::SessionLookup { .. } => "SESSION_LOOKUP",
Self::ModelNotRealtime { .. } => "MODEL_NOT_REALTIME",
Self::ProviderHasNoLiveAdapter { .. } => "PROVIDER_HAS_NO_LIVE_ADAPTER",
}
}
}