tmc_langs_csharp/
error.rs1use std::path::PathBuf;
4use thiserror::Error;
5use tmc_langs_framework::TmcError;
6use tmc_langs_util::{FileError, JsonError};
7
8#[derive(Debug, Error)]
9pub enum CSharpError {
10 #[error("Failed to parse exercise description at {0}")]
12 ParseExerciseDesc(PathBuf, #[source] JsonError),
13 #[error("Failed to parse test results at {0}")]
14 ParseTestResults(PathBuf, #[source] JsonError),
15 #[error("Could not locate cache directory")]
16 CacheDir,
17 #[error("Could not locate boostrap DLL at {0}")]
18 MissingBootstrapDll(PathBuf),
19 #[error(
20 "Failed to locate test results at {path}
21 stdout: {stdout}
22 stderr: {stderr}"
23 )]
24 MissingTestResults {
25 path: PathBuf,
26 stdout: String,
27 stderr: String,
28 },
29
30 #[error("File IO error")]
32 FileError(#[from] FileError),
33 #[error("Zip error")]
34 Zip(#[from] zip::result::ZipError),
35}
36
37impl From<CSharpError> for TmcError {
39 fn from(err: CSharpError) -> Self {
40 Self::Plugin(Box::new(err))
41 }
42}
43
44impl<T> From<CSharpError> for Result<T, TmcError> {
46 fn from(from: CSharpError) -> Self {
47 Err(TmcError::Plugin(Box::new(from)))
48 }
49}