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