gst_client_rs/error.rs
1//! Defining library errors.
2use crate::gstd_types::ResponseCode;
3use derive_more::{Display, Error};
4
5/// Possible errors of performing [`GstClient`] requests.
6///
7/// [`GstClient`]: crate::GstClient
8#[derive(Debug, Display, Error)]
9pub enum Error {
10 /// Performing HTTP request failed itself.
11 #[display(fmt = "Failed to perform HTTP request: {}", _0)]
12 RequestFailed(reqwest::Error),
13
14 /// [`GstClient`] responded with a bad [`StatusCode`].
15 ///
16 /// [`StatusCode`]: reqwest::StatusCode
17 /// [`GstClient`]: crate::GstClient
18 #[display(fmt = "API responded with status={} error={:#?}", _0, _1)]
19 BadStatus(#[error(not(source))] reqwest::StatusCode, Option<String>),
20
21 /// [`GstClient`] responded with a bad body, which cannot be deserialized.
22 ///
23 /// [`GstClient`]: crate::GstClient
24 #[display(fmt = "Failed to decode API response: {}", _0)]
25 BadBody(reqwest::Error),
26
27 /// Failed to build [`GstClient`] client because incorrect base Url
28 ///
29 /// [`GstClient`]: crate::GstClient
30 #[display(fmt = "Failed to parse base URL: {}", _0)]
31 IncorrectBaseUrl(url::ParseError),
32
33 /// Failed to create [`GstClient`] API Url
34 ///
35 /// [`GstClient`]: crate::GstClient
36 #[display(fmt = "Failed to parse URL: {}", _0)]
37 IncorrectApiUrl(url::ParseError),
38
39 /// Failed to process request on [GStD] side.
40 ///
41 /// [GStD]: https://developer.ridgerun.com/wiki/index.php/GStreamer_Daemon
42 #[display(fmt = "Failed to process request: {}", _0)]
43 GstdError(ResponseCode),
44}