1use sexprs_util::{impl_error, Traceback};
2
3#[derive(Debug, Clone, PartialEq, Eq, Copy)]
4pub enum ErrorType {
5 IOError,
6 FormatError,
7 ParserError,
8 RuntimeError,
9}
10impl std::fmt::Display for ErrorType {
11 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
12 write!(
13 f,
14 "{}",
15 match self {
16 Self::IOError => "IOError",
17 Self::FormatError => "FormatError",
18 Self::ParserError => "ParserError",
19 Self::RuntimeError => "RuntimeError",
20 }
21 )
22 }
23}
24impl_error!(Error, ErrorType);
25impl From<std::io::Error> for Error {
26 fn from(e: std::io::Error) -> Self {
27 Error::new(e, ErrorType::IOError)
28 }
29}
30impl From<iocore::Error> for Error {
31 fn from(e: iocore::Error) -> Self {
32 Error::new(e, ErrorType::IOError)
33 }
34}
35
36impl From<sexprs_parser::Error<'_>> for Error {
37 fn from(e: sexprs_parser::Error<'_>) -> Self {
38 Error::new(e, ErrorType::ParserError)
39 }
40}