weywot/backend
Dustin 2c58796b33 backend: web: Refactor error handling
Trying to make errors more ergonomic and idiomatic.  Requiring the
handler functions to return a two-tuple with the HTTP status and the
`Json` guard would have gotten cumbersome very quickly.  To make it
simpler, there are two new error enumerations:

* `Error` is a general-purpose type that can be returned from the
  service layer.  There is a variant for each type of problem that can
  occur.
* `ApiError` is specifically for the API layer, and implements the
  Rocket `Responder` trait.  This is where mapping errors to HTTP status
  codes takes place.

The `From` trait is implemented for `ApiError`, allowing `Error` values
returned from the service layer to be passed directly back from request
handlers using the `?` operator.  Additionally, the `Error` enum
implements `From` for JSON-RPC errors, essentially mapping any unhandled
error from the RPC layer to HTTP 503 Service Unavailable, indicating a
problem communicating with the daemon.
2022-01-15 22:10:12 -06:00
..
src backend: web: Refactor error handling 2022-01-15 22:10:12 -06:00
.gitignore backend: Begin server process work 2022-01-08 17:28:42 -06:00
Cargo.lock auth: Add authentication method 2022-01-11 21:37:43 -06:00
Cargo.toml auth: Add authentication method 2022-01-11 21:37:43 -06:00
rustfmt.toml backend: Begin server process work 2022-01-08 17:28:42 -06:00