metrics/recorder/
errors.rs

1use std::{error::Error, fmt};
2
3const SET_RECORDER_ERROR: &str =
4    "attempted to set a recorder after the metrics system was already initialized";
5
6/// Error returned when trying to install a global recorder when another has already been installed.
7pub struct SetRecorderError<R>(pub R);
8
9impl<R> SetRecorderError<R> {
10    /// Returns the recorder that was attempted to be set.
11    pub fn into_inner(self) -> R {
12        self.0
13    }
14}
15
16impl<R> fmt::Debug for SetRecorderError<R> {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        f.debug_struct("SetRecorderError").finish_non_exhaustive()
19    }
20}
21
22impl<R> fmt::Display for SetRecorderError<R> {
23    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
24        fmt.write_str(SET_RECORDER_ERROR)
25    }
26}
27
28impl<R> Error for SetRecorderError<R> {}