Skip to main content

Module error

Module error 

Source
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_err for commands on an existing order. “Not found” is a definite refusal (Rejected, code not_found) in map_command_err already; this is the same mapping, kept for the code that calls it.
map_order_read_err
map_err for a read of one order. Since “not found” is Rejected with code not_found in map_err already, this is the same mapping, kept for the code that calls it.