1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::io;
// use std::process::{ExitCode, Termination};
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("compile error")]
Compile,
#[error("runtime error")]
Runtime,
#[error("could not open file {path}")]
ReadFile {
path: String,
#[source]
source: io::Error,
},
#[error("Usage: clox [path]")]
Usage,
}
// Doesn't actually work with eyre... yet? But I'm
// willing to give up "nice" exit status codes for
// eyre's error handling.
// impl Termination for Error {
// fn report(self) -> ExitCode {
// ExitCode::from(match self {
// Error::Compile => 65,
// Error::Runtime => 70,
// Error::ReadFile { path, source } => 74,
// Error::Usage => 64,
// })
// }
// }