Skip to content

Commit

Permalink
db: add feature flag, add rocksdb error type for DbError
Browse files Browse the repository at this point in the history
  • Loading branch information
voidash authored and sapinb committed Aug 1, 2024
1 parent bae4055 commit 43f0f1f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions crates/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ borsh = { workspace = true }
parking_lot = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }

[features]
stubs = []
9 changes: 6 additions & 3 deletions crates/db/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ pub enum DbError {
#[error("tried to revert to index {0} above current tip {1}")]
RevertAboveCurrent(u64, u64),

#[error("not yet implemented")]
Unimplemented,

#[error("IO Error")]
IoError,

Expand All @@ -57,6 +54,12 @@ pub enum DbError {
#[error("transaction error {0}")]
TransactionError(String),

#[error(" rocksdb {0}")]
RocksDb(String),

#[error("not yet implemented")]
Unimplemented,

#[error("{0}")]
Other(String),
}
Expand Down
4 changes: 3 additions & 1 deletion crates/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

pub mod database;
pub mod errors;
pub mod stubs;
pub mod traits;
pub mod types;

#[cfg(feature = "stubs")]
pub mod stubs;

pub type DbResult<T> = anyhow::Result<T, errors::DbError>;
2 changes: 1 addition & 1 deletion crates/rocksdb-store/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ pub fn translate_rocksdb_error(err: rocksdb::Error) -> DbError {
rocksdb::ErrorKind::TimedOut => DbError::TimedOut,
rocksdb::ErrorKind::Aborted => DbError::Aborted,
rocksdb::ErrorKind::Busy => DbError::Busy,
_ => DbError::Other(err.to_string()),
_ => DbError::RocksDb(err.to_string()),
}
}
2 changes: 1 addition & 1 deletion crates/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "alpen-test-utils"
version = "0.1.0"

[dependencies]
alpen-express-db = { workspace = true }
alpen-express-db = { workspace = true, features = ["stubs"] }
alpen-express-rocksdb = { workspace = true }

anyhow = { workspace = true }
Expand Down

0 comments on commit 43f0f1f

Please sign in to comment.