Skip to content

Eliminate the .map_err(|e| e.to_string()) boilerplate #331

@wesbillman

Description

@wesbillman

There are 97 instances of .map_err(|e| e.to_string()) and another 14 of .map_err(|e| format!(...)) in lib.rs alone. This is the classic Tauri command error-handling pattern that can be cleaned up by:

Defining an AppError enum that implements Into (or just impl From for String via a wrapper)
Or using a type alias like type CmdResult = Result<T, String> with a blanket .map_err() trait extension
Tauri 2.x supports impl serde::Serialize for command errors — a custom error type with impl Fromanyhow::Error or Fromstore::Error would let you use ? directly
This would remove a huge amount of noise from every command handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions