#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::string::{String, ToString};
pub type Result<T = (), E = Error> = core::result::Result<T, E>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
Core(#[from] shepherd_core::Error),
#[error(transparent)]
Sqlite(#[from] rusqlite::Error),
#[error("migration {version} failed: {message}")]
Migration { version: i64, message: String },
#[error("migration {version} checksum mismatch: expected {expected}, found {found}")]
MigrationChecksum {
version: i64,
expected: String,
found: String,
},
#[error("migration {version} postcondition failed: {object}")]
MigrationPostcondition { version: i64, object: String },
#[error("invalid singleton publication: {0}")]
InvalidSingletonPublication(String),
#[error("singleton publication conflict for nonce `{nonce}`: {reason}")]
SingletonPublicationConflict { nonce: String, reason: String },
#[error("registry schema version {found} is ahead of the supported {supported}")]
SchemaAhead { found: i64, supported: i64 },
#[error("registry is read-only")]
ReadOnly,
#[error(
"dispatch singleton claim conflict for {project_id}/{run_id}/{role}/{lane_key}; existing agent `{agent_id}`"
)]
DispatchClaimConflict {
project_id: String,
run_id: String,
role: String,
lane_key: String,
agent_id: String,
},
#[error("invalid dispatch singleton claim: {0}")]
InvalidDispatchClaim(String),
#[error("unsafe registry path: {0}")]
UnsafePath(String),
#[error("transaction failed ({cause}) and rollback failed ({rollback})")]
TransactionRollback { cause: String, rollback: String },
#[error("{0}")]
Unknown(String),
}
impl Error {
pub fn unknown(message: impl core::fmt::Display) -> Self {
Self::Unknown(message.to_string())
}
}