Please sign in to comment.
refactor(api): reduce the number of different error kinds we return
The error-handling in this repo grew pretty organically without us giving much thought to an over-arching strategy. The end result of that was a proliferation of different error types that weren't really adding much value. The API here is simple and the 4xx responses are really limited to bad requests and bounce/complaint limit violations. Everything else is an internal server error. As such, the `error` module could be simplified by employing a blanket `Internal` error type to cover the multitude of niche errors that should never occur during normal conditions. The detail for those errors is still available in the `message` property and Sentry will still log the backtrace of course. I also noticed that the Rocket catcher stuff wasn't really being used, so pulled that out too. We have a standard JSON error format like the rest of the FxA ecosystem, and we always want the response payload to be the serialisation of that structure. One side-effect of all these changes is that the errno value has changed in most cases. However, I took care to preserve the errno for the bounce and complaint violations, because it's hard-coded in the auth server. It wouldn't have been that onerous to open a PR for commensurate changes over there, but the number of errors left here worked out in such a way that made sense not to bother.
- Loading branch information...
Showing with 338 additions and 465 deletions.
- +4 −7 src/api/healthcheck/mod.rs
- +1 −1 src/api/healthcheck/test.rs
- +1 −1 src/api/send/mod.rs
- +21 −19 src/api/send/test.rs
- +0 −9 src/bin/service.rs
- +25 −21 src/db/auth_db/mod.rs
- +10 −8 src/db/core/mod.rs
- +6 −9 src/db/delivery_problems/mod.rs
- +17 −17 src/db/delivery_problems/test.rs
- +20 −7 src/providers/mod.rs
- +12 −22 src/providers/sendgrid.rs
- +1 −11 src/providers/ses/mod.rs
- +2 −3 src/providers/ses/test.rs
- +6 −15 src/providers/smtp.rs
- +5 −10 src/providers/socketlabs.rs
- +11 −3 src/queues/mock.rs
- +9 −3 src/queues/mod.rs
- +28 −39 src/queues/sqs/mod.rs
- +1 −1 src/queues/test.rs
- +4 −4 src/types/duration/mod.rs
- +6 −6 src/types/duration/test.rs
- +45 −221 src/types/error/mod.rs
- +103 −28 src/types/error/test.rs
Oops, something went wrong.