Skip to content

Commit

Permalink
remove thiserror
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Oct 26, 2024
1 parent 6a4ade6 commit 5aaba5b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ crossbeam-skiplist = { version = "0.1", default-features = false, package = "cro
crossbeam-skiplist-mvcc = { version = "0.1" }
skl = { version = "0.18", default-features = false, features = ["alloc"] }
paste = "1"
thiserror = "1"

bytes = { version = "1", default-features = false, optional = true }
smallvec = { version = "1", default-features = false, optional = true, features = ["const_generics"] }
Expand Down
27 changes: 24 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,42 @@ use derive_where::derive_where;
use crate::memtable::BaseTable;

/// The batch error type.
#[derive(Debug, thiserror::Error)]
#[derive(Debug)]
pub enum BatchError {
/// Returned when the expected batch encoding size does not match the actual size.
#[error("the expected batch encoding size ({expected}) does not match the actual size {actual}")]
EncodedSizeMismatch {
/// The expected size.
expected: u32,
/// The actual size.
actual: u32,
},
/// Larger encoding size than the expected batch encoding size.
#[error("larger encoding size than the expected batch encoding size {0}")]
LargerEncodedSize(u32),
}

impl core::fmt::Display for BatchError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::EncodedSizeMismatch { expected, actual } => {
write!(
f,
"the expected batch encoding size ({}) does not match the actual size {}",
expected, actual
)
}
Self::LargerEncodedSize(size) => {
write!(
f,
"larger encoding size than the expected batch encoding size {}",
size
)
}
}
}
}

impl core::error::Error for BatchError {}

/// The error type.
#[derive_where(Debug; T::Error)]
pub enum Error<T: BaseTable> {
Expand Down

0 comments on commit 5aaba5b

Please sign in to comment.