1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("runtime error: {0}")]
Runtime(#[from] tauri_runtime::Error),
#[error("failed to create webview: {0}")]
CreateWebview(Box<dyn std::error::Error + Send>),
#[error("failed to create window")]
CreateWindow,
#[error("webview not found: invalid label or it was closed")]
WebviewNotFound,
#[error("failed to send message to the webview")]
FailedToSendMessage,
#[error("asset not found: {0}")]
AssetNotFound(String),
#[error("JSON error: {0}")]
Json(serde_json::Error),
#[error("unknown API: {0:?}")]
UnknownApi(Option<serde_json::Error>),
#[error("failed to execute API: {0}")]
FailedToExecuteApi(#[from] crate::api::Error),
#[error("{0}")]
Io(#[from] std::io::Error),
#[cfg(any(fs_write_binary_file, feature = "updater"))]
#[error("Failed to decode base64 string: {0}")]
Base64Decode(#[from] base64::DecodeError),
#[error("invalid icon: {0}")]
InvalidIcon(Box<dyn std::error::Error + Send>),
#[error("http client dropped or not initialized")]
HttpClientNotInitialized,
#[error("{0}")]
ApiNotEnabled(String),
#[error("'{0}' not on the allowlist (https://tauri.studio/docs/api/config#tauri.allowlist)")]
ApiNotAllowlisted(String),
#[error("invalid args for command `{0}`: {1}")]
InvalidArgs(&'static str, serde_json::Error),
#[error("error encountered during setup hook: {0}")]
Setup(Box<dyn std::error::Error + Send>),
#[cfg(feature = "updater")]
#[error("Updater: {0}")]
TauriUpdater(#[from] crate::updater::Error),
#[error("failed to initialize plugin `{0}`: {1}")]
PluginInitialization(String, String),
#[error("failed to setup dialog: provided default path `{0}` doesn't exist")]
DialogDefaultPathNotExists(PathBuf),
#[error("error encountered during tray setup: {0}")]
SystemTray(Box<dyn std::error::Error + Send>),
}
impl From<serde_json::Error> for Error {
fn from(error: serde_json::Error) -> Self {
if error.to_string().contains("unknown variant") {
Self::UnknownApi(Some(error))
} else {
Self::Json(error)
}
}
}