Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling #94

Open
NYBACHOK opened this issue Jul 23, 2024 · 4 comments
Open

Error handling #94

NYBACHOK opened this issue Jul 23, 2024 · 4 comments

Comments

@NYBACHOK
Copy link

Problem to solve

Error handling is omitted from tasks. Panic, Result and Option never get mentioned in idioms chapter nor ecosystem.

Proposal

Add task to 3_ecosystem where it would be required to refactor library code from manual mapping errors to usage of thiserror + write tests with usage of anyhow.

Prior art

https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html#unrecoverable-errors-with-panic

Alternatives

Error handling mentioned in 5_zero2prod.

Links & references

https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html#unrecoverable-errors-with-panic

https://docs.rs/thiserror/latest/thiserror/

https://docs.rs/anyhow/latest/anyhow/

@NamesMark
Copy link

NamesMark commented Jul 26, 2024

Agree! I could've sworn it was mentioned, but you are right, it's not here :)

There's multiple levels of error handling and it would be nice to explain this progression from "lazy and fast" to "proper and structured"

Result<(), ()> -> Result<(), String> -> Result<(), CustomError>
anyhow/eyre -> thiserror

@NYBACHOK
Copy link
Author

Well. This topic may be expanted panic recomendation too

@NamesMark
Copy link

The problem I see is that module 3 is already quite heavy. Maybe we can add it to the end of module 2, as it's kinda also a part of the "idioms", and the error crates can be considered secondary to this topic?

@kilterdev
Copy link

The problem I see is that module 3 is already quite heavy. Maybe we can add it to the end of module 2, as it's kinda also a part of the "idioms", and the error crates can be considered secondary to this topic?

Could not agree more on this. I support the idea of ​​pushing this topic straight in to the pile of the (2)nd chapter.
It really feels more natural being in this category, after all the approach of proper error handling is at the very core of being idiomatic (in the context of Rust)...

Also it's a bit strange such an important subject was not covered on the early stage, where it truly belongs. Tho, i believe there were reasons for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants