1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, TectonError>;
7
8#[derive(Debug, Error)]
10pub enum TectonError {
11 #[error("configuration error: {0}")]
12 Config(String),
13
14 #[error("invalid input: {0}")]
15 InvalidInput(String),
16
17 #[error("not found: {0}")]
18 NotFound(String),
19
20 #[error("storage error: {0}")]
21 Storage(String),
22
23 #[error("compute error: {0}")]
24 Compute(String),
25
26 #[error("I/O error: {0}")]
27 Io(#[from] std::io::Error),
28
29 #[error("serialization error: {0}")]
30 Serde(#[from] serde_json::Error),
31
32 #[error("internal error: {0}")]
33 Internal(String),
34}
35
36impl TectonError {
37 pub fn config(msg: impl Into<String>) -> Self {
39 Self::Config(msg.into())
40 }
41
42 pub fn invalid_input(msg: impl Into<String>) -> Self {
44 Self::InvalidInput(msg.into())
45 }
46
47 pub fn storage(msg: impl Into<String>) -> Self {
49 Self::Storage(msg.into())
50 }
51
52 pub fn compute(msg: impl Into<String>) -> Self {
54 Self::Compute(msg.into())
55 }
56}