tmc_langs_make/
error.rs

1//! Error type for the make plugin.
2
3use std::{num::ParseIntError, path::PathBuf};
4use thiserror::Error;
5use tmc_langs_framework::{ExitStatus, TmcError};
6use tmc_langs_util::FileError;
7
8#[derive(Error, Debug)]
9pub enum MakeError {
10    #[error("No exercise found at {0}")]
11    NoExerciseFound(PathBuf),
12    #[error("Can't parse exercise description: could not find {0}")]
13    CantFindAvailablePoints(PathBuf),
14    #[error("Failed to run tests without valgrind. Exit code: {0:?}, stderr: {1}")]
15    RunningTests(ExitStatus, String),
16    #[error("Failed to run tests with valgrind. Exit code: {0:?}, stderr: {1}")]
17    RunningTestsWithValgrind(ExitStatus, String),
18    #[error("Failed to parse valgrind logs: could not find pids")]
19    NoPidsInValgrindLogs,
20
21    #[error("Failed to parse XML at {0}")]
22    XmlParseError(PathBuf, #[source] serde_xml_rs::Error),
23    #[error(transparent)]
24    ParseIntError(#[from] ParseIntError),
25
26    #[error("File IO error")]
27    FileError(#[from] FileError),
28    #[error(transparent)]
29    Tmc(#[from] TmcError),
30}
31
32// conversion from plugin error to TmcError::Plugin
33impl From<MakeError> for TmcError {
34    fn from(other: MakeError) -> TmcError {
35        TmcError::Plugin(Box::new(other))
36    }
37}
38
39// conversion from plugin error to a tmc result
40impl<T> From<MakeError> for Result<T, TmcError> {
41    fn from(from: MakeError) -> Self {
42        Err(TmcError::Plugin(Box::new(from)))
43    }
44}