Function map_command_err
pub fn map_command_err(err: AlorApiError) -> ErrorExpand description
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.
| Protocol error | Public error |
|---|---|
Http without a status (no answer, a break, a timeout) or with status 500 and above | [Error::Unknown] |
Parse (the answer cannot be read), Ws | [Error::Unknown] |
Http with status 400 to 499, except 429 | [Error::Rejected] with code http_<status> and the broker’s message |
everything else (429, Auth, NotFound, …) | as in map_err |
§Examples
use brokapi_alor_protocol::error::AlorApiError;
use brokapi_alor::error::map_command_err;
use brokapi_core::Error;
// No answer at all: the order may exist.
let lost = AlorApiError::Http { status: None, message: "timeout".into() };
assert!(matches!(map_command_err(lost), Error::Unknown));
// The broker answered 503: it may have acted.
let busy = AlorApiError::Http { status: Some(503), message: "busy".into() };
assert!(matches!(map_command_err(busy), Error::Unknown));
// The broker answered 400: it did nothing.
let bad = AlorApiError::Http { status: Some(400), message: "no".into() };
match map_command_err(bad) {
Error::Rejected { code, .. } => assert_eq!(code, "http_400"),
other => panic!("{other:?}"),
}