string-eyre 0.1.0

Convenience traits for dealing with errors that don't want to eyre
Documentation
  • Coverage
  • 40%
    2 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 4.74 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.1 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Michcioperz/string-eyre
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Michcioperz

string-eyre

Has this happened to you?

error[E0599]: the method `wrap_err` exists for enum `Result<(), tauri::Error>`, but its trait bounds were not satisfied
   --> src/main.rs:60:6
    |
60  |     .wrap_err("error while running tauri application")?;
    |      ^^^^^^^^
    |
   ::: /home/michcioperz/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-1.0.0-beta.8/src/error.rs:10:1
    |
10  | pub enum Error {
    | --------------
    | |
    | doesn't satisfy `tauri::Error: Sync`
    | doesn't satisfy `tauri::Error: eyre::context::ext::StdError`
    |
   ::: /home/michcioperz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:503:1
    |
503 | pub enum Result<T, E> {
    | --------------------- doesn't satisfy `_: WrapErr<(), tauri::Error>`
    |
    = note: the following trait bounds were not satisfied:
            `tauri::Error: eyre::context::ext::StdError`
            which is required by `Result<(), tauri::Error>: WrapErr<(), tauri::Error>`
            `tauri::Error: Sync`
            which is required by `Result<(), tauri::Error>: WrapErr<(), tauri::Error>`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `app` due to previous error

Sometimes you feel very tired and decide that, okay, perhaps I will need to stringify the error:

    .map_err(|e| e.to_string())

And that works okay, unless the error doesn't stringify, at which point you grow angrier and just:

    .map_err(|e| format!("{:?}", e))

But String isn't actually an error type, so eyre rightfully doesn't see it as such, so you actually want:

    .map_err(|e| eyre!("{:?}", e))

And probably more people should scream at me, but I'd like to have shorthands for this where I don't type this heresy over and over again, but instead write:

    .debug_to_eyre()