{"record":{"id":"591303bdf4f8f922","repo":"tonhowtf/omniget","slug":"e-to-string-mod","errorCode":null,"errorMessage":"e.to_string()","messagePattern":"e\\.to_string\\(\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/commands/tools/mod.rs","lineNumber":48,"sourceCode":"pub mod twitch;\npub mod video;\npub mod vimeo;\npub mod x;\npub mod youtube;\n\nuse std::sync::Arc;\n\nuse omniget_core::core::tools::ProgressFn;\nuse tauri::Emitter;\n\npub(crate) fn progress(app: &tauri::AppHandle) -> ProgressFn {\n    let app = app.clone();\n    Arc::new(move |p| {\n        let _ = app.emit(\"tool-progress\", p);\n    })\n}\n\npub(crate) fn err(e: impl std::fmt::Display) -> String {\n    e.to_string()\n}\n","sourceCodeStart":30,"sourceCodeEnd":51,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/commands/tools/mod.rs#L30-L51","documentation":"`err` is a tiny helper in the Tauri command layer that converts any Rust error value implementing Display into a String so it can be returned from an #[tauri::command] as a Result<T, String>. The throw site `e.to_string()` is where any underlying error (io, rusqlite, serialization, etc.) is flattened. The message the developer actually sees is whatever the inner error's Display impl produced, so this function is the funnel through which all backend command errors surface to the frontend as a rejected invoke() promise.","triggerScenarios":"Any Tauri command in this crate returns Err(err(e)) — e.g. a command fails on file I/O, database access, or argument deserialization, and the resulting Display string is serialized across the IPC boundary to the webview as the invoke() rejection value.","commonSituations":"Developers hit this when debugging why an invoke() promise rejected with an opaque string: the inner error type was collapsed to a String so the original error kind can no longer be matched; command handlers fail due to wrong args, missing files, or locked resources, and the stringified message lands in the frontend.","solutions":["Log the full error in Rust before stringifying (tracing::error!(\"{e:#}\")) so context is not lost when collapsed to a String","Match on the underlying error type in the command before calling err() to return a structured/typed error code instead of a free-form string","Check the command's arguments and environment (paths, permissions, config) based on the Display message content","On the frontend, wrap invoke() in try/catch and treat the rejected string as a user-facing message"],"exampleFix":"// before\npub(crate) fn err(e: impl std::fmt::Display) -> String {\n    e.to_string()\n}\n// after\npub(crate) fn err(e: impl std::fmt::Display) -> String {\n    tracing::error!(\"command failed: {e}\");\n    e.to_string()\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await invoke(\"my_command\", args);\n} catch (e) {\n  // e is the stringified Rust error from err()\n  const msg = typeof e === \"string\" ? e : errorText(e);\n  console.error(\"command failed:\", msg);\n}","preventionTips":["Always invoke() inside try/catch since Rust errors arrive as rejected strings","Log the full error on the Rust side before it is collapsed to a String","Keep err() calls localized so command failures can be traced to their source"],"tags":["rust","tauri","error-handling","ipc"],"backgroundTag":"api-error-response","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}