Skip to content

Commit 12b8d18

Browse files
refactor!: remove unnecessary error enum and result type aliases (#7875)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent ed32257 commit 12b8d18

File tree

6 files changed

+35
-53
lines changed

6 files changed

+35
-53
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri': 'major:breaking'
3+
---
4+
5+
Removed `tauri::path::Error` and added its variants to `tauri::Error`.

core/tauri/src/error.rs

+23
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,30 @@ pub enum Error {
107107
#[cfg(all(desktop, feature = "tray-icon"))]
108108
#[cfg_attr(doc_cfg, doc(cfg(all(desktop, feature = "tray-icon"))))]
109109
BadTrayIcon(#[from] tray_icon::BadIcon),
110+
/// Path does not have a parent.
111+
#[error("path does not have a parent")]
112+
NoParent,
113+
/// Path does not have an extension.
114+
#[error("path does not have an extension")]
115+
NoExtension,
116+
/// Path does not have a basename.
117+
#[error("path does not have a basename")]
118+
NoBasename,
119+
/// Cannot resolve current directory.
120+
#[error("failed to read current dir: {0}")]
121+
CurrentDir(std::io::Error),
122+
/// Unknown path.
123+
#[cfg(not(target_os = "android"))]
124+
#[error("unknown path")]
125+
UnknownPath,
126+
/// Failed to invoke mobile plugin.
127+
#[cfg(target_os = "android")]
128+
#[error(transparent)]
129+
PluginInvoke(#[from] crate::plugin::mobile::PluginInvokeError),
110130
/// window not found.
111131
#[error("window not found")]
112132
WindowNotFound,
113133
}
134+
135+
/// `Result<T, ::tauri::Error>`
136+
pub type Result<T> = std::result::Result<T, Error>;

core/tauri/src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ pub use cocoa;
6565
#[cfg(target_os = "macos")]
6666
#[doc(hidden)]
6767
pub use embed_plist;
68-
/// The Tauri error enum.
69-
pub use error::Error;
68+
pub use error::{Error, Result};
7069
#[cfg(target_os = "ios")]
7170
#[doc(hidden)]
7271
pub use swift_rs;
@@ -161,9 +160,6 @@ pub use plugin::mobile::{handle_android_plugin_response, send_channel_data};
161160
#[doc(hidden)]
162161
pub use tauri_runtime_wry::wry;
163162

164-
/// `Result<T, ::tauri::Error>`
165-
pub type Result<T> = std::result::Result<T, Error>;
166-
167163
/// A task to run on the main thread.
168164
pub type SyncTask = Box<dyn FnOnce() + Send>;
169165

core/tauri/src/path/error.rs

-42
This file was deleted.

core/tauri/src/path/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
1414
use serialize_to_javascript::{default_template, DefaultTemplate, Template};
1515

1616
mod commands;
17-
mod error;
18-
pub use error::*;
17+
pub use crate::error::*;
1918

2019
#[cfg(target_os = "android")]
2120
mod android;

core/tauri/src/plugin.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
use crate::{
88
app::PageLoadPayload,
9+
error::Error,
910
ipc::{Invoke, InvokeHandler},
1011
utils::config::PluginConfig,
1112
AppHandle, RunEvent, Runtime, Window,
@@ -17,13 +18,13 @@ use url::Url;
1718

1819
use std::{fmt, result::Result as StdResult, sync::Arc};
1920

21+
/// The result type of Tauri plugin module.
22+
pub type Result<T> = StdResult<T, Box<dyn std::error::Error>>;
23+
2024
/// Mobile APIs.
2125
#[cfg(mobile)]
2226
pub mod mobile;
2327

24-
/// The result type of Tauri plugin module.
25-
pub type Result<T> = StdResult<T, Box<dyn std::error::Error>>;
26-
2728
/// The plugin interface.
2829
pub trait Plugin<R: Runtime>: Send {
2930
/// The plugin name. Used as key on the plugin config object.
@@ -592,7 +593,7 @@ impl<R: Runtime> PluginStore<R> {
592593
app,
593594
config.0.get(plugin.name()).cloned().unwrap_or_default(),
594595
)
595-
.map_err(|e| crate::Error::PluginInitialization(plugin.name().to_string(), e.to_string()))
596+
.map_err(|e| Error::PluginInitialization(plugin.name().to_string(), e.to_string()))
596597
})
597598
}
598599

0 commit comments

Comments
 (0)