1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use hyper::http::uri::InvalidUri;
use std::{borrow::Cow, error::Error};
use url::ParseError as UrlParseError;
#[allow(missing_docs)]
pub type CometdResult<T> = Result<T, CometdError>;
#[allow(missing_docs)]
#[derive(Debug, thiserror::Error)]
pub enum CometdError {
#[error("Endpoint wasn't set in builder.")]
MissingEndpoint,
#[error("Url parse error: `{0}`.")]
InvalidUrl(#[from] UrlParseError),
#[error("Url parse error: `{0}`.")]
InvalidUri(#[from] InvalidUri),
#[error("Error during handshake request: `{0}`.")]
HandshakeError(Box<dyn Error>),
#[error("Error during subscribe request: `{0}`.")]
SubscribeError(Box<dyn Error>),
#[error("Error during connect request: `{0}`.")]
ConnectError(Box<dyn Error>),
#[error("Error during disconnect request: `{0}`.")]
DisconnectError(Box<dyn Error>),
#[error("Got unexpected error: `{0}`")]
UnexpectedError(Box<dyn Error>),
}
impl CometdError {
#[inline(always)]
pub(crate) fn unexpected_error<E: Error + 'static>(err: E) -> Self {
Self::UnexpectedError(err.into())
}
#[inline(always)]
pub(crate) fn handshake_error<E: Error + 'static>(err: E) -> Self {
Self::HandshakeError(err.into())
}
#[inline(always)]
pub(crate) fn subscribe_error<E: Error + 'static>(err: E) -> Self {
Self::SubscribeError(err.into())
}
#[inline(always)]
pub(crate) fn connect_error<E: Error + 'static>(err: E) -> Self {
Self::ConnectError(err.into())
}
#[inline(always)]
pub(crate) fn disconnect_error<E: Error + 'static>(err: E) -> Self {
Self::DisconnectError(err.into())
}
}
#[derive(Debug, thiserror::Error)]
pub(crate) enum InnerError {
#[error("{0}")]
WrongResponse(Cow<'static, str>),
#[error("Make handshake before request.")]
MissingClientId,
}