tower_batch_control/
error.rs
1use crate::BoxError;
4use std::{fmt, sync::Arc};
5
6#[derive(Debug)]
8pub struct ServiceError {
9 inner: Arc<BoxError>,
10}
11
12pub struct Closed {
14 _p: (),
15}
16
17impl ServiceError {
20 pub(crate) fn new(inner: BoxError) -> ServiceError {
21 let inner = Arc::new(inner);
22 ServiceError { inner }
23 }
24
25 pub(crate) fn clone(&self) -> ServiceError {
27 ServiceError {
28 inner: self.inner.clone(),
29 }
30 }
31}
32
33impl fmt::Display for ServiceError {
34 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
35 write!(fmt, "batching service failed: {}", self.inner)
36 }
37}
38
39impl std::error::Error for ServiceError {
40 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
41 Some(&**self.inner)
42 }
43}
44
45impl Closed {
48 pub(crate) fn new() -> Self {
49 Closed { _p: () }
50 }
51}
52
53impl fmt::Debug for Closed {
54 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
55 fmt.debug_tuple("Closed").finish()
56 }
57}
58
59impl fmt::Display for Closed {
60 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
61 fmt.write_str("batch worker closed unexpectedly")
62 }
63}
64
65impl std::error::Error for Closed {}