simplify error handling
This commit is contained in:
parent
e431dc89a8
commit
bd652c956f
8 changed files with 94 additions and 147 deletions
12
src/app.rs
12
src/app.rs
|
@ -1,7 +1,5 @@
|
|||
use semver::Version;
|
||||
|
||||
use crate::Error;
|
||||
|
||||
/// Gets the application name.
|
||||
///
|
||||
/// # Example
|
||||
|
@ -12,7 +10,7 @@ use crate::Error;
|
|||
/// ```
|
||||
#[inline(always)]
|
||||
pub async fn get_name() -> crate::Result<String> {
|
||||
let js_val = inner::getName().await.map_err(Error::Other)?;
|
||||
let js_val = inner::getName().await?;
|
||||
|
||||
Ok(serde_wasm_bindgen::from_value(js_val)?)
|
||||
}
|
||||
|
@ -28,7 +26,7 @@ pub async fn get_name() -> crate::Result<String> {
|
|||
/// ```
|
||||
#[inline(always)]
|
||||
pub async fn get_version() -> crate::Result<Version> {
|
||||
let js_val = inner::getVersion().await.map_err(Error::Other)?;
|
||||
let js_val = inner::getVersion().await?;
|
||||
|
||||
Ok(serde_wasm_bindgen::from_value(js_val)?)
|
||||
}
|
||||
|
@ -44,7 +42,7 @@ pub async fn get_version() -> crate::Result<Version> {
|
|||
/// ```
|
||||
#[inline(always)]
|
||||
pub async fn get_tauri_version() -> crate::Result<Version> {
|
||||
let js_val = inner::getTauriVersion().await.map_err(Error::Other)?;
|
||||
let js_val = inner::getTauriVersion().await?;
|
||||
|
||||
Ok(serde_wasm_bindgen::from_value(js_val)?)
|
||||
}
|
||||
|
@ -60,7 +58,7 @@ pub async fn get_tauri_version() -> crate::Result<Version> {
|
|||
/// ```
|
||||
#[inline(always)]
|
||||
pub async fn show() -> crate::Result<()> {
|
||||
inner::show().await.map_err(Error::Other)
|
||||
Ok(inner::show().await?)
|
||||
}
|
||||
|
||||
/// Hides the application on macOS.
|
||||
|
@ -74,7 +72,7 @@ pub async fn show() -> crate::Result<()> {
|
|||
/// ```
|
||||
#[inline(always)]
|
||||
pub async fn hide() -> crate::Result<()> {
|
||||
inner::hide().await.map_err(Error::Other)
|
||||
Ok(inner::hide().await?)
|
||||
}
|
||||
|
||||
mod inner {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue