use std::fmt;
use aws_smithy_runtime_api::box_error::BoxError;
#[non_exhaustive]
#[derive(Debug)]
pub struct ObservabilityError {
kind: ErrorKind,
source: BoxError,
}
#[non_exhaustive]
#[derive(Debug)]
pub enum ErrorKind {
Other,
}
impl ObservabilityError {
pub fn new<E>(kind: ErrorKind, err: E) -> Self
where
E: Into<BoxError>,
{
Self {
kind,
source: err.into(),
}
}
pub fn kind(&self) -> &ErrorKind {
&self.kind
}
}
impl fmt::Display for ObservabilityError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.kind {
ErrorKind::Other => write!(f, "unclassified error"),
}
}
}
impl std::error::Error for ObservabilityError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(self.source.as_ref())
}
}
#[non_exhaustive]
#[derive(Debug)]
pub struct GlobalTelemetryProviderError {
reason: &'static str,
}
impl GlobalTelemetryProviderError {
pub fn new(reason: &'static str) -> Self {
Self { reason }
}
}
impl std::error::Error for GlobalTelemetryProviderError {}
impl fmt::Display for GlobalTelemetryProviderError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "GlobalTelemetryProviderError: {}", self.reason)
}
}