error: remove <BackendError> generic

we can just map each backend error variant <-> our error as needed
This commit is contained in:
hinto.janai 2024-02-13 17:34:44 -05:00
parent 4a13dc22e8
commit 6eb0981829
No known key found for this signature in database
GPG key ID: D47CE05FA175A499

View file

@ -14,15 +14,11 @@ use crate::constants::DATABASE_BACKEND;
/// be needed if we can convert all error types into /// be needed if we can convert all error types into
/// "generic" database errors. /// "generic" database errors.
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum InitError<BackendError: Debug> { pub enum InitError {
/// TODO /// TODO
#[error("database PATH is inaccessible: {0}")] #[error("database PATH is inaccessible: {0}")]
Path(std::io::Error), Path(std::io::Error),
/// TODO
#[error("{DATABASE_BACKEND} error: {0}")]
Backend(BackendError),
/// TODO /// TODO
/// ///
/// An unknown error occurred. /// An unknown error occurred.
@ -46,8 +42,8 @@ pub enum InitError<BackendError: Debug> {
feature = "borsh", feature = "borsh",
derive(borsh::BorshSerialize, borsh::BorshDeserialize) derive(borsh::BorshSerialize, borsh::BorshDeserialize)
)] )]
#[derive(thiserror::Error, Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] #[derive(thiserror::Error, Debug)]
pub enum RuntimeError<BackendError: Debug> { pub enum RuntimeError {
/// The given key already existed in the database. /// The given key already existed in the database.
/// ///
/// The string inside is the output of /// The string inside is the output of
@ -83,7 +79,9 @@ pub enum RuntimeError<BackendError: Debug> {
/// The expected database version was not the version found. /// The expected database version was not the version found.
#[error("database version mismatch: expected {expected}, found {found}")] #[error("database version mismatch: expected {expected}, found {found}")]
VersionMismatch { VersionMismatch {
/// The expected database version.
expected: &'static str, expected: &'static str,
/// The database version found.
found: &'static str, found: &'static str,
}, },
@ -94,10 +92,6 @@ pub enum RuntimeError<BackendError: Debug> {
#[error("database maximum parallel readers reached")] #[error("database maximum parallel readers reached")]
MaxReaders, MaxReaders,
/// An unknown backend-specific error occured.
#[error("{DATABASE_BACKEND} error: {0}")]
Backend(BackendError),
// TODO: this could be removed once we have all errors figured out. // TODO: this could be removed once we have all errors figured out.
/// An unknown error occurred. /// An unknown error occurred.
#[error("unknown error: {0}")] #[error("unknown error: {0}")]