Skip to content

mismatched types expected enum Result<_, Box<(dyn StdError + 'static)>> found enum Result<_, anyhow::Error> #12575

Answered by evanwmart
hahazexia asked this question in Q&A
Discussion options

You must be logged in to vote

So the error type given doesn't match the error type that is received from your create_cache_dir()

It expects to see a type:
Result<(), Box<dyn std::error::Error>>
but gets:
Result<(), anyhow::Error>

I think this is basically saying to try something like:

tauri::Builder::default()
    .setup(|app| {
        create_cache_dir().map_err(|e| {
            app.emit("err-msg", format!("create cache dir failed!"))
                .unwrap();
            e.into() // nifty way to convert the error type into Box<dyn std::error::Error>
        })?;
        Ok(())
    })
    .plugin(tauri_plugin_opener::init())
    .invoke_handler(tauri::generate_handler![add, add_new_task])
    .run(tauri::generate_c…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hahazexia
Comment options

@hahazexia
Comment options

Answer selected by hahazexia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants