pub struct ApiErrorResponse {
pub timestamp: Option<u64>,
pub trace_id: Option<String>,
pub error_type: String,
pub errors: Vec<ValidationFieldError>,
}Expand description
The JSON body the broker sends with a non-success status.
The client reads it to pick the BcsApiError variant. You see this type only if you parse a raw
reply yourself.
§Examples
use brokapi_bcs_protocol::error::ApiErrorResponse;
let body = r#"{"timestamp":1760860000000,"traceId":"t-1","type":"VALIDATION_ERROR",
"errors":[{"type":"INVALID_VALUE","field":"orderQuantity"}]}"#;
let e: ApiErrorResponse = serde_json::from_str(body)?;
assert_eq!(e.error_type, "VALIDATION_ERROR");
assert_eq!(e.trace_id.as_deref(), Some("t-1"));
assert_eq!(e.errors.len(), 1);Fields§
§timestamp: Option<u64>Time of the error. The docs give an integer and no unit (not verified, looks like epoch milliseconds).
trace_id: Option<String>The broker’s trace id of the request, to quote to the broker support.
error_type: StringClass of the error (JSON field type). The docs list VALIDATION_ERROR, RESOURCE_EXHAUSTED,
USER_BLOCKED, BAD_REQUEST, NOT_FOUND, UNAUTHORIZED, FORBIDDEN, CONFLICT,
INTERNAL_SERVER_ERROR, SESSION_NOT_FOUND_ERROR, SESSION_EXPIRED_ERROR,
SESSION_FAILED_ERROR and USER_NOT_FOUND. Only the first and NOT_FOUND get their own
BcsApiError variant.
errors: Vec<ValidationFieldError>Per-field details, empty when the error is not about fields.
Trait Implementations§
Source§impl Debug for ApiErrorResponse
impl Debug for ApiErrorResponse
Source§impl<'de> Deserialize<'de> for ApiErrorResponse
impl<'de> Deserialize<'de> for ApiErrorResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ApiErrorResponse
impl RefUnwindSafe for ApiErrorResponse
impl Send for ApiErrorResponse
impl Sync for ApiErrorResponse
impl Unpin for ApiErrorResponse
impl UnsafeUnpin for ApiErrorResponse
impl UnwindSafe for ApiErrorResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more