tcp-over-http/src/base/err_utils.rs

13 lines
422 B
Rust

use std::fmt::Display;
use std::io::ErrorKind;
/// Encapsulate errors in [`std::io::Error`] with a message
pub fn encpasulate_error<E: Display, F: ToString>(e: E, msg: F) -> std::io::Error {
std::io::Error::new(ErrorKind::Other, format!("{}:\n* {}", msg.to_string(), e))
}
/// Create a new [`std::io::Error`]
pub fn new_err(msg: &str) -> std::io::Error {
std::io::Error::new(ErrorKind::Other, msg.to_string())
}