#[derive(Debug, thiserror::Error)]
#[error("recorder: http {status}: {body}")]
pub struct HttpError {
pub status: u16,
pub body: String,
}
impl HttpError {
pub fn transient(&self) -> bool {
self.status >= 500 || self.status == 429
}
}
#[derive(Debug, thiserror::Error)]
pub enum RecordError {
#[error(transparent)]
Http(#[from] HttpError),
#[error("recorder: request failed: {0}")]
Transport(#[from] reqwest::Error),
#[error("recorder: flush timed out")]
Timeout,
#[error("recorder: buffer full")]
BufferFull,
}
impl RecordError {
pub fn transient(&self) -> bool {
match self {
RecordError::Http(e) => e.transient(),
RecordError::Transport(_) | RecordError::Timeout => true,
RecordError::BufferFull => false,
}
}
}
#[derive(Debug, thiserror::Error)]
#[error("recorder: drain timed out with events pending")]
pub struct DrainTimeout;