add constructor for error

This commit is contained in:
KitsuneCafe 2024-02-04 06:35:02 -05:00
parent f698687a2d
commit 3059a3b774

View file

@ -12,6 +12,13 @@ pub struct Error {
}
impl Error {
pub fn new<E: std::error::Error + 'static>(message: String, source: E) -> Self {
Self {
message,
source: Some(Box::new(source)),
}
}
fn wrap<E: std::error::Error + 'static>(value: E) -> Option<Box<dyn std::error::Error>> {
Some(Box::new(value))
}