fallout_core/core_api/
error.rs1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum CoreErrorCode {
6 Io,
7 Parse,
8 GameDetectionAmbiguous,
9 UnsupportedOperation,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq)]
13pub struct CoreError {
14 pub code: CoreErrorCode,
15 pub message: String,
16}
17
18impl CoreError {
19 pub fn new(code: CoreErrorCode, message: impl Into<String>) -> Self {
20 Self {
21 code,
22 message: message.into(),
23 }
24 }
25}
26
27impl fmt::Display for CoreError {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 write!(f, "{:?}: {}", self.code, self.message)
30 }
31}
32
33impl Error for CoreError {}