Stream: project-error-handling

Topic: error handling patterns


view this post on Zulip Gus Gutoski (Feb 26 2021 at 22:17):

Re-posting from #new members as advised:
Gus Gutoski said:

Hi folks. I'm new to Rust. Building a cryptography library. Looking for the right error handling pattern. Found this zulip via #project-error-handling . It seems there's contention on how best to handle errors in Rust. I found this article interesting https://sled.rs/errors . Would someone be so kind as to refer me to the state-of-the-art on error handling patterns? Thank you.

view this post on Zulip Jane Lusby (Feb 26 2021 at 22:18):

hello, happy to help

view this post on Zulip Jane Lusby (Feb 26 2021 at 22:18):

rn we're still in early days working on a book documenting many of the best practices

view this post on Zulip Jane Lusby (Feb 26 2021 at 22:19):

I did give a talk at rustconf that went over many of the basics https://www.youtube.com/watch?v=rAF8mLI0naQ

view this post on Zulip Gus Gutoski (Feb 26 2021 at 22:19):

The book sounds interesting.

view this post on Zulip Gus Gutoski (Feb 26 2021 at 22:19):

thanks for the link! I'll definitely take a look

view this post on Zulip Jane Lusby (Feb 26 2021 at 22:20):

my pleasure, if you have any additional questions lmk

view this post on Zulip Gus Gutoski (Feb 27 2021 at 01:31):

Thanks for the video. It's information dense with lots for me to chew on. Do you have an opinion on the nested Result pattern described in the sled article? https://sled.rs/errors

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:42):

Gus Gutoski said:

Thanks for the video. It's information dense with lots for me to chew on. Do you have an opinion on the nested Result pattern described in the sled article? https://sled.rs/errors

I like it a lot

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:42):

nested results are waaay better than 3 state result equivalents

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:43):

something like

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:43):

enum Result<T, E, F> {
    Ok(T),
    Err(E),
    Fail(F),
}

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:44):

which is how nom has handled non-recoverable parser errors in the past

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:44):

not sure if they've updated that since

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:44):

pub enum Err<E> {
    Incomplete(Needed),
    Error(E),
    Failure(E),
}

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:44):

looks like no

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:45):

hmm

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:45):

actually no

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:45):

this is an error type

view this post on Zulip Jane Lusby (Feb 27 2021 at 01:45):

im clearly misremembering things


Last updated: Jan 26 2022 at 13:46 UTC