aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..ff25db7
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,42 @@
1use crate::lisp::error::LispError;
2
3use std::{error, fmt, io};
4
5use sdl2::ttf;
6
7#[derive(Debug)]
8pub enum AppError {
9 Lisp(LispError),
10 File(io::Error),
11 Sdl(String),
12 SdlTTF(SdlTTFError),
13}
14
15impl fmt::Display for AppError {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 match self {
18 Self::Lisp(e) => write!(f, "lisp error: {}", e),
19 Self::File(e) => write!(f, "file error: {}", e),
20 Self::Sdl(e) => write!(f, "sdl2 error: {}", e),
21 Self::SdlTTF(e) => write!(f, "ttf error: {}", e),
22 }
23 }
24}
25
26#[derive(Debug)]
27pub enum SdlTTFError {
28 Font(ttf::FontError),
29 Init(ttf::InitError),
30}
31
32impl fmt::Display for SdlTTFError {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 match self {
35 Self::Font(e) => write!(f, "font error: {}", e),
36 Self::Init(e) => write!(f, "init error: {}", e),
37 }
38 }
39}
40
41impl error::Error for AppError {}
42impl error::Error for SdlTTFError {}