Skip to content

Commit 7589590

Browse files
committed
feat(left-right-tlcache): use thiserror
Use thiserror for ReadHandleCacheError to easily integrate cache errors. Signed-off-by: Fredi Raspall <[email protected]>
1 parent e27e49a commit 7589590

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

left-right-tlcache/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ license = "Apache-2.0"
88
[dependencies]
99
left-right = { workspace = true }
1010
ahash = { workspace = true }
11+
thiserror = { workspace = true }

left-right-tlcache/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use std::collections::HashMap;
3434
use std::hash::Hash;
3535
use std::rc::Rc;
3636
use std::thread::LocalKey;
37+
use thiserror::Error;
3738

3839
pub trait ReadHandleProvider {
3940
type Data;
@@ -46,9 +47,11 @@ pub trait ReadHandleProvider {
4647
fn get_factory(&self, key: &Self::Key) -> Option<&ReadHandleFactory<Self::Data>>;
4748
}
4849

49-
#[derive(Debug)]
50+
#[derive(Debug, PartialEq, Error)]
5051
pub enum ReadHandleCacheError<K> {
52+
#[error("Reader not found for key {0}")]
5153
NotFound(K),
54+
#[error("Reader for key {0} is not accessible")]
5255
NotAccessible(K),
5356
}
5457

0 commit comments

Comments
 (0)