rustenium_core/
error.rs

1use thiserror::Error;
2use rustenium_bidi_commands::{ErrorResponse, ResultData};
3
4#[derive(Debug, Error)]
5pub enum SessionSendError {
6    #[error("Remote End Returned an Error Response: {0:?}")]
7    ErrorResponse(ErrorResponse),
8    #[error("Could not receive response for command in time")]
9    ResponseReceiveTimeoutError(ResponseReceiveTimeoutError)
10}
11#[derive(Debug, Error)]
12pub enum CommandResultError {
13    #[error("Invalid Result gotten For Command")]
14    InvalidResultTypeError(ResultData),
15    #[error("Error Occurred with Command")]
16    SessionSendError(SessionSendError)
17}
18
19#[derive(Debug, Error)]
20pub struct  ResponseReceiveTimeoutError;
21
22impl std::fmt::Display for ResponseReceiveTimeoutError {
23    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
24        write!(f, "Could not receive response for command in time")
25    }
26}
27
28#[derive(Debug, Error)]
29pub enum PostDataError {
30    #[error("No POST data available")]
31    NoPostData,
32    #[error("Failed to parse POST data as JSON: {0}")]
33    JsonParseError(#[from] serde_json::Error),
34    #[error("POST data is valid JSON but not a JSON object")]
35    NotJsonObject,
36}