1use std::{env::VarError, error::Error as E, fmt::Display};
3use url::ParseError;
4
5#[derive(Debug)]
7pub struct Error {
8 message: String,
9}
10
11impl From<&str> for Error {
12 fn from(value: &str) -> Self {
13 Error {
14 message: String::from(value),
15 }
16 }
17}
18
19impl From<VarError> for Error {
20 fn from(value: VarError) -> Self {
21 Error {
22 message: value.to_string(),
23 }
24 }
25}
26
27impl From<ParseError> for Error {
28 fn from(value: ParseError) -> Self {
29 Error {
30 message: value.to_string(),
31 }
32 }
33}
34
35impl From<String> for Error {
36 fn from(value: String) -> Self {
37 Error { message: value }
38 }
39}
40
41impl From<()> for Error {
42 fn from(_: ()) -> Self {
43 Error {
44 message: String::from("An unspecified error occurred"),
45 }
46 }
47}
48
49impl From<std::io::Error> for Error {
50 fn from(value: std::io::Error) -> Self {
51 Error {
52 message: value.to_string(),
53 }
54 }
55}
56
57impl Display for Error {
58 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
59 write!(f, "{}", self.message)
60 }
61}
62
63impl E for Error {}