ave_core/helpers/sink/
error.rs1use thiserror::Error;
5
6#[derive(Debug, Clone, Error)]
8pub enum SinkError {
9 #[error("failed to build HTTP client: {0}")]
11 ClientBuild(String),
12
13 #[error("failed to send auth request: {0}")]
15 AuthRequest(String),
16
17 #[error("auth endpoint error: {0}")]
19 AuthEndpoint(String),
20
21 #[error("failed to parse token response: {0}")]
23 TokenParse(String),
24
25 #[error("failed to send data to sink: {message}")]
27 SendRequest { message: String, retryable: bool },
28
29 #[error("sink authentication failed")]
31 Unauthorized,
32
33 #[error("sink rejected data format: {message}")]
35 UnprocessableEntity { message: String },
36
37 #[error("sink returned HTTP {status}: {message}")]
39 HttpStatus {
40 status: u16,
41 message: String,
42 retryable: bool,
43 },
44
45 #[error("sink shutdown in progress")]
47 Shutdown,
48}
49
50impl SinkError {
51 pub const fn is_transient(&self) -> bool {
52 match self {
53 Self::SendRequest { retryable, .. }
54 | Self::HttpStatus { retryable, .. } => *retryable,
55 Self::ClientBuild(_)
56 | Self::AuthRequest(_)
57 | Self::AuthEndpoint(_)
58 | Self::TokenParse(_)
59 | Self::Unauthorized
60 | Self::UnprocessableEntity { .. }
61 | Self::Shutdown => false,
62 }
63 }
64}