aws_smithy_observability/
error.rs1use std::fmt;
9
10use aws_smithy_runtime_api::box_error::BoxError;
11
12#[non_exhaustive]
14#[derive(Debug)]
15pub struct ObservabilityError {
16 kind: ErrorKind,
17 source: BoxError,
18}
19
20#[non_exhaustive]
22#[derive(Debug)]
23pub enum ErrorKind {
24 Other,
26}
27
28impl ObservabilityError {
29 pub fn new<E>(kind: ErrorKind, err: E) -> Self
31 where
32 E: Into<BoxError>,
33 {
34 Self {
35 kind,
36 source: err.into(),
37 }
38 }
39
40 pub fn kind(&self) -> &ErrorKind {
42 &self.kind
43 }
44}
45
46impl fmt::Display for ObservabilityError {
47 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48 match &self.kind {
49 ErrorKind::Other => write!(f, "unclassified error"),
50 }
51 }
52}
53
54impl std::error::Error for ObservabilityError {
55 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
56 Some(self.source.as_ref())
57 }
58}
59
60#[non_exhaustive]
62#[derive(Debug)]
63pub struct GlobalTelemetryProviderError {
64 reason: &'static str,
65}
66
67impl GlobalTelemetryProviderError {
68 pub fn new(reason: &'static str) -> Self {
70 Self { reason }
71 }
72}
73
74impl std::error::Error for GlobalTelemetryProviderError {}
75
76impl fmt::Display for GlobalTelemetryProviderError {
77 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
78 write!(f, "GlobalTelemetryProviderError: {}", self.reason)
79 }
80}