Skip to content

Commit

Permalink
Use thiserror for v2::api::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpringle committed Aug 29, 2023
1 parent 016669f commit eb2e922
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions firewood/src/v2/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,21 @@ pub fn vec_into_batch<K: KeyType, V: ValueType>(value: Vec<(K, V)>) -> Batch<K,
}

/// Errors returned through the API
#[derive(Debug)]
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
/// A given hash key is not available in the database
HashNotFound {
provided: HashKey,
},
#[error("Hash not found for key: {provided:?}")]
HashNotFound { provided: HashKey },

/// Incorrect root hash for commit
IncorrectRootHash {
provided: HashKey,
current: HashKey,
},
#[error("Incorrect root hash for commit: {provided:?} != {current:?}")]
IncorrectRootHash { provided: HashKey, current: HashKey },

#[error("IO error: {0}")]
IO(std::io::Error),

#[error("Invalid proposal")]
InvalidProposal,
}

Expand Down

0 comments on commit eb2e922

Please sign in to comment.