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. |
||
---|---|---|
.. | ||
src | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
rustfmt.toml |