Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions worker/src/kv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ pub enum KvError {
InvalidKvStore(String),
}

unsafe impl Send for KvError {}
unsafe impl Sync for KvError {}

impl std::fmt::Display for KvError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
KvError::JavaScript(value) => write!(f, "js error: {value:?}"),
KvError::Serialization(e) => write!(f, "unable to serialize/deserialize: {e}"),
KvError::InvalidKvStore(binding) => write!(f, "invalid kv store: {binding}"),
}
}
}

impl std::error::Error for KvError {}

impl From<KvError> for JsValue {
fn from(val: KvError) -> Self {
match val {
Expand Down