cpast/lang_runner/
runner_error_types.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use core::fmt;
use std::error::Error;

#[derive(Debug)]
pub(crate) enum RunnerErrorType {
    UnsupportedLanguage,
    CodeRunFailed,
    FileNotFound,
}

impl fmt::Display for RunnerErrorType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let error_description = match self {
            RunnerErrorType::UnsupportedLanguage => "Unsupported language",
            RunnerErrorType::CodeRunFailed => "Code run failed",
            RunnerErrorType::FileNotFound => "File not found",
        };

        write!(
            f,
            "[Runner Error] RunnerErrorType::{:?} {}",
            self, error_description
        )
    }
}

impl Error for RunnerErrorType {
    fn cause(&self) -> Option<&dyn Error> {
        None
    }

    fn source(&self) -> Option<&(dyn Error + 'static)> {
        None
    }
}