|
1 | 1 | use histogram::Histogram; |
2 | 2 | use std::sync::atomic::{AtomicU64, Ordering}; |
3 | | -use std::sync::{Arc, Mutex, MutexGuard, PoisonError}; |
| 3 | +use std::sync::{Arc, Mutex}; |
4 | 4 |
|
5 | 5 | const ORDER_TYPE: Ordering = Ordering::Relaxed; |
6 | 6 |
|
7 | 7 | #[derive(Debug)] |
8 | | -pub enum MetricsError<'a> { |
9 | | - Poison(PoisonError<MutexGuard<'a, Histogram>>), |
10 | | - Histogram(&'static str), |
| 8 | +pub struct MetricsError { |
| 9 | + cause: &'static str, |
11 | 10 | } |
12 | 11 |
|
13 | | -impl<'a> From<PoisonError<MutexGuard<'a, Histogram>>> for MetricsError<'a> { |
14 | | - fn from(err: PoisonError<MutexGuard<'_, Histogram>>) -> MetricsError { |
15 | | - MetricsError::Poison(err) |
16 | | - } |
17 | | -} |
18 | | - |
19 | | -impl From<&'static str> for MetricsError<'_> { |
| 12 | +impl From<&'static str> for MetricsError { |
20 | 13 | fn from(err: &'static str) -> MetricsError { |
21 | | - MetricsError::Histogram(err) |
| 14 | + MetricsError { cause: err } |
22 | 15 | } |
23 | 16 | } |
24 | 17 |
|
25 | | -impl std::fmt::Display for MetricsError<'_> { |
| 18 | +impl std::fmt::Display for MetricsError { |
26 | 19 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
27 | | - write!(f, "{:?}", self) |
| 20 | + write!(f, "metrics error: {}", self.cause) |
28 | 21 | } |
29 | 22 | } |
30 | 23 |
|
|
0 commit comments