feat: add Display implementaion for public and internal FailedTo
This commit is contained in:
@@ -59,6 +59,30 @@ impl std::error::Error for FailedTo {}
|
||||
|
||||
impl std::fmt::Display for FailedTo {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
|
||||
todo!()
|
||||
match self {
|
||||
FailedTo::ComposeFilter => write!(f, "Failed to compose filter statement"),
|
||||
FailedTo::ConvertEntity => write!(f, "Failed to convert from Entity to type"),
|
||||
FailedTo::ConvertObject => write!(f, "Failed to convert from type to Entity"),
|
||||
FailedTo::ConvertValue => write!(f, "Failed to convert from Value to type"),
|
||||
FailedTo::ExecutePredicate(errors) => {
|
||||
write!(f, "Failed to execute predicate: ")?;
|
||||
for (i, err) in errors.iter().enumerate() {
|
||||
if i > 0 {
|
||||
write!(f, "; ")?;
|
||||
}
|
||||
write!(f, "{}", err)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
FailedTo::InitDatabase => write!(f, "Failed to initialize the database"),
|
||||
FailedTo::LoadFromDB => write!(f, "Failed to load data from the database"),
|
||||
FailedTo::LockCatalog => {
|
||||
write!(f, "Failed to lock catalog in a multithread environment")
|
||||
}
|
||||
FailedTo::MapAttribute => write!(f, "Failed to map a database row to an attribute"),
|
||||
FailedTo::MapEntity => write!(f, "Failed to map a database row to an entity"),
|
||||
FailedTo::PersistCatalog => write!(f, "Failed to persist the catalog to the database"),
|
||||
FailedTo::SQLite(e) => write!(f, "SQLite error: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,3 +18,20 @@ pub enum FailedTo {
|
||||
/// Failed to prepare a SQL statement for execution.
|
||||
PrepareStatement(rusqlite::Error),
|
||||
}
|
||||
|
||||
impl std::error::Error for FailedTo{}
|
||||
|
||||
impl std::fmt::Display for FailedTo {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
|
||||
match self {
|
||||
FailedTo::BeginTransaction(e) => write!(f, "Failed to begin transaction: {}", e),
|
||||
FailedTo::BuildStatement => write!(f, "Failed to build SQL statement"),
|
||||
FailedTo::CommitTransaction(e) => write!(f, "Failed to commit transaction: {}", e),
|
||||
FailedTo::ExecuteBatch(e) => write!(f, "Failed to execute batch: {}", e),
|
||||
FailedTo::ExecuteQuery(e) => write!(f, "Failed to execute query: {}", e),
|
||||
FailedTo::ExecuteStatement(e) => write!(f, "Failed to execute statement: {}", e),
|
||||
FailedTo::OpenConnection(e) => write!(f, "Failed to open connection: {}", e),
|
||||
FailedTo::PrepareStatement(e) => write!(f, "Failed to prepare statement: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user