Module error
Expand description
Maps the errors of the protocol layer ([BcsApiError]) to the public [brokapi_core::Error].
The protocol layer first sorts an HTTP answer. A body with type = "VALIDATION_ERROR" becomes
ValidationError, type = "NOT_FOUND" becomes NotFound, any other JSON body with a type
becomes HttpError with that type as the message. A body that is not that JSON becomes
RateLimitExceeded for HTTP 429 and HttpError with the body text for any other status. This
module then picks the public error.
There are two mappings, and the difference matters. map_err is for reads. map_command_err
and map_order_cmd_err are for commands that change the account, where “no answer” must never
look like “nothing happened”.
Functions§
- map_
cid_ err - Maps a failure to encode a client order id to [
Error::Config], with the text of the original error. - map_
command_ err - A command that failed: only answers that prove the broker did not act become definite errors.
No answer, a break, HTTP 5xx or an unreadable answer may have reached the broker:
Error::Unknown, never retried by the library. - map_
config_ err - Maps a failure to build a client from the configuration to [
Error::Config], with the text of the original error. - map_err
- Maps a failed read (or a failed step before a command was sent) to a public error.
- map_
order_ cmd_ err map_command_errfor commands on an existing order. “Not found” is a definite refusal (Rejected, codenot_found) inmap_command_erralready; this is the same mapping, kept for the code that calls it.- map_
order_ read_ err map_errfor a read of one order. Since “not found” isRejectedwith codenot_foundinmap_erralready, this is the same mapping, kept for the code that calls it.