1use std::fmt::{Display, Formatter};
2
3#[derive(Debug)]
5pub struct BoxedError(Box<dyn std::error::Error + Send + Sync>);
6
7impl Display for BoxedError {
8 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
9 self.0.fmt(f)
10 }
11}
12
13pub(crate) fn transform_error<
14 R: std::error::Error,
15 P: std::error::Error + Send + Sync + 'static,
16>(
17 e: rcore::Error<R, P>,
18) -> rcore::Error<R, BoxedError> {
19 match e {
20 rcore::Error::Request(e) => rcore::Error::Request(e),
21 rcore::Error::Provider(e) => rcore::Error::Provider(BoxedError(Box::new(e))),
22 rcore::Error::NotImplemented => rcore::Error::NotImplemented,
23 }
24}
25
26impl std::error::Error for BoxedError {}