feat(error): add Rust AppError enum and migrate command modules

- AppError enum with 10 variants (Database, Auth, Filesystem, Ipc, NotFound,
  Validation, Sidecar, Config, Network, Internal) + serde tag serialization
- From impls for rusqlite::Error, std::io::Error, serde_json::Error
- Migrated 9 command modules from Result<T, String> to Result<T, AppError>
- Frontend receives structured {kind, detail} objects via IPC
This commit is contained in:
Hibryda 2026-03-18 01:22:04 +01:00
parent 365c420901
commit 8b3b0ab720
11 changed files with 319 additions and 81 deletions

View file

@ -1,5 +1,6 @@
use tauri::State;
use crate::AppState;
use crate::error::AppError;
use crate::pty::PtyOptions;
#[tauri::command]
@ -7,13 +8,13 @@ use crate::pty::PtyOptions;
pub fn pty_spawn(
state: State<'_, AppState>,
options: PtyOptions,
) -> Result<String, String> {
state.pty_manager.spawn(options)
) -> Result<String, AppError> {
state.pty_manager.spawn(options).map_err(AppError::sidecar)
}
#[tauri::command]
pub fn pty_write(state: State<'_, AppState>, id: String, data: String) -> Result<(), String> {
state.pty_manager.write(&id, &data)
pub fn pty_write(state: State<'_, AppState>, id: String, data: String) -> Result<(), AppError> {
state.pty_manager.write(&id, &data).map_err(AppError::sidecar)
}
#[tauri::command]
@ -22,12 +23,12 @@ pub fn pty_resize(
id: String,
cols: u16,
rows: u16,
) -> Result<(), String> {
state.pty_manager.resize(&id, cols, rows)
) -> Result<(), AppError> {
state.pty_manager.resize(&id, cols, rows).map_err(AppError::sidecar)
}
#[tauri::command]
#[tracing::instrument(skip(state))]
pub fn pty_kill(state: State<'_, AppState>, id: String) -> Result<(), String> {
state.pty_manager.kill(&id)
pub fn pty_kill(state: State<'_, AppState>, id: String) -> Result<(), AppError> {
state.pty_manager.kill(&id).map_err(AppError::sidecar)
}