tower_abci/buffer4/
error.rs1use crate::BoxError;
4use std::{fmt, sync::Arc};
5
6#[derive(Debug)]
11pub struct ServiceError {
12 inner: Arc<BoxError>,
13}
14
15pub struct Closed {
17 _p: (),
18}
19
20impl ServiceError {
23 pub(crate) fn new(inner: BoxError) -> ServiceError {
24 let inner = Arc::new(inner);
25 ServiceError { inner }
26 }
27
28 pub(crate) fn clone(&self) -> ServiceError {
30 ServiceError {
31 inner: self.inner.clone(),
32 }
33 }
34}
35
36impl fmt::Display for ServiceError {
37 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
38 write!(fmt, "buffered service failed: {}", self.inner)
39 }
40}
41
42impl std::error::Error for ServiceError {
43 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
44 Some(&**self.inner)
45 }
46}
47
48impl Closed {
51 pub(crate) fn new() -> Self {
52 Closed { _p: () }
53 }
54}
55
56impl fmt::Debug for Closed {
57 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
58 fmt.debug_tuple("Closed").finish()
59 }
60}
61
62impl fmt::Display for Closed {
63 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
64 fmt.write_str("buffer's worker closed unexpectedly")
65 }
66}
67
68impl std::error::Error for Closed {}