1use rustenium_bidi_definitions::base::ErrorResponse;
2use rustenium_cdp_definitions::base::ErrorResponse as CdpErrorResponse;
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum SessionSendError {
7 #[error("Remote End Returned an Error Response: {0:?}")]
8 ErrorResponse(ErrorResponse),
9 #[error("Could not receive response for command in time")]
10 ResponseReceiveTimeoutError(ResponseReceiveTimeoutError)
11}
12#[derive(Debug, Error)]
13pub enum CommandResultError {
14 #[error("Invalid Result gotten For Command")]
15 InvalidResultTypeError(serde_json::Value),
16 #[error("Error Occurred with Command")]
17 SessionSendError(SessionSendError)
18}
19
20#[derive(Debug, Error)]
21pub struct ResponseReceiveTimeoutError;
22
23impl std::fmt::Display for ResponseReceiveTimeoutError {
24 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
25 write!(f, "Could not receive response for command in time")
26 }
27}
28
29#[derive(Debug, Error)]
30pub enum CdpSessionSendError {
31 #[error("CDP Error Response: {0}")]
32 ErrorResponse(CdpErrorResponse),
33 #[error("Could not receive response for CDP command in time")]
34 ResponseReceiveTimeoutError(ResponseReceiveTimeoutError),
35}
36
37#[derive(Debug, Error)]
38pub enum CdpCommandResultError {
39 #[error("Invalid Result gotten For CDP Command")]
40 InvalidResultTypeError(serde_json::Value),
41 #[error("Error Occurred with CDP Command")]
42 SessionSendError(CdpSessionSendError),
43}
44
45#[derive(Debug, Error)]
46#[error("Failed to kill process")]
47pub struct ProcessKillError;
48
49#[derive(Debug, Error)]
50pub enum PostDataError {
51 #[error("No POST data available")]
52 NoPostData,
53 #[error("Failed to parse POST data as JSON: {0}")]
54 JsonParseError(#[from] serde_json::Error),
55 #[error("POST data is valid JSON but not a JSON object")]
56 NotJsonObject,
57}