Skip to main content

map_order_read_err

Function map_order_read_err 

Source
pub fn map_order_read_err(err: BcsApiError) -> Error
Expand description

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.

Used by order_state. The way out of an Unknown is to ask again until the order is found or the answer stays not_found long enough ([Error::Unknown]).

§Examples

use brokapi_bcs_protocol::error::BcsApiError;
use brokapi_bcs::error::map_order_read_err;
use brokapi_core::Error;

match map_order_read_err(BcsApiError::NotFound { trace_id: None }) {
    Error::Rejected { code, .. } => assert_eq!(code, "not_found"),
    other => panic!("{other:?}"),
}
assert!(matches!(map_order_read_err(BcsApiError::RateLimitExceeded), Error::RateLimited { .. }));