HomePhabricator

[Chronik] Add `parse_error_status` to parse error msgs as HTTP status

Description

[Chronik] Add parse_error_status to parse error msgs as HTTP status

Summary:
We handle errors using thiserror and eyre, but neither allow us to attach an HTTP status code to the error. We could use a procedual macro (e.g. bitcoinsuite-error-derive), however, this has many downsides.

Instead, we opt for a much simpler approach: Simply encode the HTTP status in the error message as a prefix. This way a DB failure can be prefixed with e.g. "500: ", and when a queried tx is not found in the chain, we can prefix the error with "404: ".

Test Plan: cargo test

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D13203

Details

Provenance
tobias_ruckAuthored on Feb 28 2023, 13:27
tobias_ruckPushed on Mar 1 2023, 11:28
Reviewer
Restricted Project
Differential Revision
D13203: [Chronik] Add `parse_error_status` to parse error msgs as HTTP status
Parents
rABCf25e5123332a: Remove dead code in mempool
Branches
Unknown
Tags
Unknown