tauri_plugin_powersync/
error.rs1use crate::handle::Handle;
2use powersync::error::PowerSyncError;
3use serde::{Serialize, Serializer};
4
5#[derive(Debug, thiserror::Error)]
6pub enum PowerSyncTauriError {
7 #[error("{0}")]
8 PowerSync(#[from] PowerSyncError),
9 #[error("Handle {0} is not valid for the caller.")]
10 IllegalHandle(Handle),
11 #[error("Passed handle of wrong type")]
12 IllegalHandleType,
13 #[error("Could not obtain connection within timeout")]
14 TimeoutExpired,
15}
16
17impl Serialize for PowerSyncTauriError {
18 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19 where
20 S: Serializer,
21 {
22 serializer.serialize_str(self.to_string().as_ref())
23 }
24}
25
26pub type Result<T> = std::result::Result<T, PowerSyncTauriError>;