Skip to main content

ryft_core/
errors.rs

1use thiserror::Error;
2
3#[derive(Error, Clone, Debug, Eq, PartialEq)]
4pub enum Error {
5    #[error("runtime error: {message}")]
6    RuntimeError { message: String, backtrace: String },
7
8    #[error(
9        "{}",
10        match paths.as_deref() {
11            None => "got more parameters than expected".to_string(),
12            Some(paths) => format!(
13                "got more parameters than expected; unused parameter paths: {}",
14                paths.iter().map(|path| format!("'{path}'")).collect::<Vec<_>>().join(", "),
15            ),
16        }
17    )]
18    UnusedParameters { paths: Option<Vec<String>> },
19
20    #[error(
21        "{}",
22        match paths.as_deref() {
23            None => format!("got fewer parameters than expected; expected at least {expected_count}"),
24            Some(paths) => format!(
25                "got fewer parameters than expected; expected at least {expected_count}; missing parameter paths: {}",
26                paths.iter().map(|path| format!("'{path}'")).collect::<Vec<_>>().join(", "),
27            ),
28        }
29    )]
30    MissingParameters { expected_count: usize, paths: Option<Vec<String>> },
31
32    #[error(
33        "got ambiguous parameter values while combining parameterized values; conflicting values: {}",
34        values.iter().map(|value| format!("'{value}'")).collect::<Vec<_>>().join(", "),
35    )]
36    AmbiguousParameterCombination { values: Vec<String> },
37}