use super::{super::problem::*, common::*};
pub trait GlossProblemResult<OkT, ErrorT> {
fn into_gloss<GlossErrorT>(self) -> Result<OkT, Problem>
where
ErrorT: ToString,
GlossErrorT: 'static + std::error::Error + From<String> + Send + Sync;
#[track_caller]
fn gloss(self) -> Result<OkT, Problem>
where
Self: Sized,
ErrorT: ToString,
{
self.into_gloss::<GlossError>()
}
#[track_caller]
fn into_thread_problem(self) -> Result<OkT, Problem>
where
Self: Sized,
ErrorT: ToString,
{
self.into_gloss::<ThreadError>()
}
}
impl<OkT, ErrorT> GlossProblemResult<OkT, ErrorT> for Result<OkT, ErrorT> {
#[track_caller]
fn into_gloss<GlossErrorT>(self) -> Result<OkT, Problem>
where
ErrorT: ToString,
GlossErrorT: 'static + std::error::Error + From<String> + Send + Sync,
{
match self {
Ok(ok) => Ok(ok),
Err(error) => Err(GlossErrorT::from(error.to_string()).into_problem()),
}
}
}