1use serde_json::Error as JsonError;
4use thiserror::Error;
5
6pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, Error)]
9pub enum Error {
10 #[error("JSON error: {0}")]
11 JSON(#[from] JsonError),
12
13 #[error("Error parsing model: {0}")]
14 Parse(String),
15
16 #[error("{0} is not yet implemented.")]
17 NotImplemented(String),
18
19 #[error(transparent)]
20 Other(#[from] anyhow::Error),
21}
22
23#[macro_export]
25macro_rules! throw_error {
26 ($msg:expr) => {{
27 let error_msg = format!(
28 " {} | File: {} | Function: {} | Line: {}",
29 $msg,
30 file!(),
31 module_path!(),
32 line!()
33 );
34 Err(Error::Parse(error_msg))
35 }};
36}
37
38#[macro_export]
40macro_rules! error {
41 ($msg:expr) => {{
42 let error_msg = format!(
43 " {} | File: {} | Function: {} | Line: {}",
44 $msg,
45 file!(),
46 module_path!(),
47 line!()
48 );
49 Error::Parse(error_msg)
50 }};
51}