Skip to content

Commit 499c8b4

Browse files
authored
feat: add Send+Sync+Display traits to KvError (#847)
1 parent b524d98 commit 499c8b4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

worker/src/kv/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ pub enum KvError {
173173
InvalidKvStore(String),
174174
}
175175

176+
unsafe impl Send for KvError {}
177+
unsafe impl Sync for KvError {}
178+
179+
impl std::fmt::Display for KvError {
180+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
181+
match self {
182+
KvError::JavaScript(value) => write!(f, "js error: {value:?}"),
183+
KvError::Serialization(e) => write!(f, "unable to serialize/deserialize: {e}"),
184+
KvError::InvalidKvStore(binding) => write!(f, "invalid kv store: {binding}"),
185+
}
186+
}
187+
}
188+
189+
impl std::error::Error for KvError {}
190+
176191
impl From<KvError> for JsValue {
177192
fn from(val: KvError) -> Self {
178193
match val {

0 commit comments

Comments
 (0)