1use crate::parser;
2use std::fmt;
3use std::ops::Range;
4
5#[derive(Debug)]
9pub enum JsonPopError<'a> {
10 Parse(crate::parser::ParseError<'a>),
11 Io(std::io::Error),
12 TestError(crate::extra::test_utils::TestError<'a>),
14}
15
16#[derive(Debug)]
22pub enum TopLevelError {
23 TestingError,
24 ParseError,
25 Io(std::io::Error),
26}
27
28impl<'a> From<JsonPopError<'a>> for TopLevelError {
29 fn from(it: JsonPopError<'a>) -> TopLevelError {
30 match it {
31 JsonPopError::Parse(_) => {
32 TopLevelError::ParseError
34 }
35 JsonPopError::Io(err) => TopLevelError::Io(err),
36 JsonPopError::TestError(_) => TopLevelError::TestingError,
37 }
38 }
39}
40
41#[derive(Debug)]
44pub enum CompilationError {
45 LexicalError { range: Range<usize> },
46 NumericalError { range: Range<usize> },
47 UnterminatedStringLiteral { range: Range<usize> },
48}
49
50impl fmt::Display for CompilationError {
51 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
52 write!(f, "{:#?}", self)
53 }
54}
55
56impl<'a> fmt::Display for JsonPopError<'a> {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 write!(f, "{:#?}", self)
59 }
60}
61
62impl<'a> From<std::io::Error> for JsonPopError<'a> {
63 fn from(err: std::io::Error) -> Self {
64 JsonPopError::Io(err)
65 }
66}
67
68impl<'a> From<parser::ParseError<'a>> for JsonPopError<'a> {
69 fn from(err: parser::ParseError<'a>) -> Self {
70 JsonPopError::Parse(err)
71 }
72}