tauri_plugin_libsql/
error.rs1use serde::{ser::Serializer, Serialize};
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7 #[error(transparent)]
8 Io(#[from] std::io::Error),
9 #[error(transparent)]
10 Libsql(#[from] libsql::Error),
11 #[error("invalid connection url: {0}")]
12 InvalidDbUrl(String),
13 #[error("database {0} not loaded")]
14 DatabaseNotLoaded(String),
15 #[error("unsupported datatype: {0}")]
16 UnsupportedDatatype(String),
17 #[error("operation not supported: {0}")]
18 OperationNotSupported(String),
19 #[error("json error: {0}")]
20 Json(#[from] serde_json::Error),
21 #[cfg(mobile)]
22 #[error(transparent)]
23 PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
24}
25
26impl Serialize for Error {
27 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
28 where
29 S: Serializer,
30 {
31 serializer.serialize_str(self.to_string().as_ref())
32 }
33}