3 ms·
there are answers in the thread you linked that show how easy and clean the error handling can be. it can look just like a more-efficient `except` clauses with
by skrtskrt 1y ago
there are answers in the thread you linked that show how easy and clean the error handling can be.
it can look just like a more-efficient `except` clauses with all the safety, clarity, and convenience that enums provide.
Here's an example:
* Implementing an error type with enums: https://git.deuxfleurs.fr/Deuxfleurs/garage/src/branch/main/src/api/k2v/error.rs https://git.deuxfleurs.fr/Deuxfleurs/garage/src/branch/main/...
* Which derives from a more general error type with even more helpful enums: https://git.deuxfleurs.fr/Deuxfleurs/garage/src/branch/main/src/api/common/common_error.rs https://git.deuxfleurs.fr/Deuxfleurs/garage/src/branch/main/...
* then some straightforward handling of the error: https://git.deuxfleurs.fr/Deuxfleurs/garage/src/branch/main/src/api/common/generic_server.rs#L228-L240 https://git.deuxfleurs.fr/Deuxfleurs/garage/src/branch/main/...