devsoc-unsw / chaos

The eventual repository for the CHAOS Hiring and Offers System - used to manage sending and receiving of applications, interviews and results.
https://chaos.csesoc.app
Other
24 stars 5 forks source link

Error handling framework #473

Open KavikaPalletenne opened 1 month ago

KavikaPalletenne commented 1 month ago

Set up error handling with Axum, so all Err and None errors bubble up and are returned as a HTTP response.

KavikaPalletenne commented 1 month ago

Some examples: https://github.com/tokio-rs/axum/blob/main/examples/error-handling/src/main.rs

fritzrehde commented 3 weeks ago

What exactly do you want? Is this about logging or reporting terminal errors?

KavikaPalletenne commented 2 weeks ago

anyhow does not seem to be the best crate for our use case. It hides every type of error inside it's own anyhow::Error type. However, we need to return different server responses based on each error, and thus, the thiserror crate seems like a better candidate.

fritzrehde commented 2 weeks ago

Yup, therror is great! It's usually used more in libraries, where you want to expose your own error types to users of your library so those users can figure out which of your errors to handle in what way. But I'd argue anyhow is the "I don't want to think too much about errors and just want to print sth to the screen"-type of solution, so organizing different failure cases in thiserror is nicer in my opinion for a sizeable project like Chaos.