1use std::fmt;
2
3use crate::diagnostic::Diagnostics;
4
5#[derive(Debug)]
6#[non_exhaustive]
7pub enum Error {
8 ParseErrors(Diagnostics),
9 FullMoonError(Vec<(String, full_moon::Error)>),
10}
11
12impl fmt::Display for Error {
13 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
14 match self {
15 Error::ParseErrors(parse_error) => write!(formatter, "{}", parse_error),
16 Error::FullMoonError(full_moon_errors) => {
17 let text = full_moon_errors
18 .iter()
19 .map(|(s, e)| format!("Full-Moon: {}\n in {}", e, s))
20 .collect::<Vec<String>>()
21 .join("\n");
22
23 write!(formatter, "{}", text)
24 }
25 }
26 }
27}
28
29impl std::error::Error for Error {}