Skip to main content

floe_core/
errors.rs

1use std::fmt;
2
3use crate::log::emit_log;
4
5#[derive(Debug)]
6pub struct ConfigError(pub String);
7
8impl fmt::Display for ConfigError {
9    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10        write!(f, "{}", self.0)
11    }
12}
13
14impl std::error::Error for ConfigError {}
15
16#[derive(Debug)]
17pub struct RunError(pub String);
18
19impl fmt::Display for RunError {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21        write!(f, "{}", self.0)
22    }
23}
24
25impl std::error::Error for RunError {}
26
27#[derive(Debug)]
28pub struct StorageError(pub String);
29
30impl fmt::Display for StorageError {
31    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32        write!(f, "{}", self.0)
33    }
34}
35
36impl std::error::Error for StorageError {}
37
38#[derive(Debug)]
39pub struct IoError(pub String);
40
41impl fmt::Display for IoError {
42    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43        write!(f, "{}", self.0)
44    }
45}
46
47impl std::error::Error for IoError {}
48
49pub fn emit(
50    run_id: &str,
51    entity: Option<&str>,
52    input: Option<&str>,
53    code: Option<&str>,
54    message: &str,
55) {
56    emit_log("error", run_id, entity, input, code, message);
57}