use std::backtrace::Backtrace;
use crate::StringError;
impl StringError<(), ()>
{
pub fn new(msg: impl Into<String>) -> Self {
Self {
msg: msg.into(),
bt : (),
err: (),
}
}
}
impl StringError<(), Backtrace>
{
pub fn with_backtrace(msg: impl Into<String>) -> Self {
let msg = msg.into();
let bt = Backtrace::force_capture();
Self { msg, bt, err: () }
}
}
impl<E: Sized> StringError<E, ()>
{
pub fn with_err<R: Into<E>>(msg: impl Into<String>) -> impl FnOnce(R) -> Self {
move |err| Self {
msg: msg.into(),
bt: (), err:
err.into()
}
}
}
impl<E: Sized> StringError<E, Backtrace>
{
pub fn with_err_backtrace<R: Into<E>>(msg: impl Into<String>) -> impl FnOnce(R) -> Self {
move |err| Self {
msg: msg.into(),
bt: Backtrace::force_capture(),
err: err.into()
}
}
}