return structured errors from commands (wip)

This commit is contained in:
jfmonty2 committed 2022-12-23 11:34:17 -08:00
1 parent 2943634248
commit df6b362a31
8 files changed
+82 -62

No files matched your search

+5 -4
View File
@@ -1,6 +1,7 @@
use serde::{Serialize, Deserialize};
use tauri::State;
use crate::errors::*;
use crate::config::AppConfig;
use crate::clientinfo::Client;
use crate::state::{AppState, Session, Credentials};
@@ -35,10 +36,10 @@ pub fn respond(response: RequestResponse, app_state: State<'_, AppState>) -> Res
#[tauri::command]
pub async fn unlock(passphrase: String, app_state: State<'_, AppState>) -> Result<(), String> {
pub async fn unlock(passphrase: String, app_state: State<'_, AppState>) -> Result<(), SerializeError<UnlockError>> {
app_state.decrypt(&passphrase)
.await
.map_err(|e| e.to_string())
.map_err(|e| SerializeError::from(e))
}
@@ -58,10 +59,10 @@ pub async fn save_credentials(
credentials: Credentials,
passphrase: String,
app_state: State<'_, AppState>
) -> Result<(), String> {
) -> Result<(), SerializeError<UnlockError>> {
app_state.save_creds(credentials, &passphrase)
.await
.map_err(|e| {eprintln!("{e:?}"); e.to_string()})
.map_err(|e| SerializeError::from(e))
}