connection_string/
error.rs
1use std::error;
2use std::fmt::{self, Display};
3
4#[derive(Debug)]
6pub struct Error {
7 msg: String,
8}
9
10impl Error {
12 pub fn new(msg: &str) -> Self {
14 Self {
15 msg: msg.to_owned(),
16 }
17 }
18}
19
20impl From<std::num::ParseIntError> for Error {
21 fn from(err: std::num::ParseIntError) -> Self {
22 Self {
23 msg: format!("{}", err),
24 }
25 }
26}
27
28impl Display for Error {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 write!(f, "Conversion error: {}", self.msg)
31 }
32}
33
34impl error::Error for Error {}