tonhowtf/omniget · error

e.to_string()

Error message

e.to_string()

What it means

`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.

Solutions

  1. Log the full error in Rust before stringifying (tracing::error!("{e:#}")) so context is not lost when collapsed to a String
  2. 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
  3. Check the command's arguments and environment (paths, permissions, config) based on the Display message content
  4. On the frontend, wrap invoke() in try/catch and treat the rejected string as a user-facing message

Example fix

// before
pub(crate) fn err(e: impl std::fmt::Display) -> String {
    e.to_string()
}
// after
pub(crate) fn err(e: impl std::fmt::Display) -> String {
    tracing::error!("command failed: {e}");
    e.to_string()
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await invoke("my_command", args);
} catch (e) {
  // e is the stringified Rust error from err()
  const msg = typeof e === "string" ? e : errorText(e);
  console.error("command failed:", msg);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/591303bdf4f8f922. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/commands/tools/mod.rs:48

pub mod twitch;
pub mod video;
pub mod vimeo;
pub mod x;
pub mod youtube;

use std::sync::Arc;

use omniget_core::core::tools::ProgressFn;
use tauri::Emitter;

pub(crate) fn progress(app: &tauri::AppHandle) -> ProgressFn {
    let app = app.clone();
    Arc::new(move |p| {
        let _ = app.emit("tool-progress", p);
    })
}

pub(crate) fn err(e: impl std::fmt::Display) -> String {
    e.to_string()
}

View on GitHub (pinned to 8600b91f42)