|
| 1 | +//! Error type for C# |
| 2 | +use std::path::PathBuf; |
| 3 | +use std::process::ExitStatus; |
| 4 | +use thiserror::Error; |
| 5 | +use tmc_langs_framework::TmcError; |
| 6 | + |
| 7 | +#[derive(Debug, Error)] |
| 8 | +pub enum CSharpError { |
| 9 | + #[error("Failed to create file {0}")] |
| 10 | + CreateFile(PathBuf, #[source] std::io::Error), |
| 11 | + #[error("Failed to write file {0}")] |
| 12 | + WriteFile(PathBuf, #[source] std::io::Error), |
| 13 | + #[error("Failed to read file {0}")] |
| 14 | + ReadFile(PathBuf, #[source] std::io::Error), |
| 15 | + #[error("Failed to remove file {0}")] |
| 16 | + RemoveFile(PathBuf, #[source] std::io::Error), |
| 17 | + #[error("Failed to create dir {0}")] |
| 18 | + CreateDir(PathBuf, #[source] std::io::Error), |
| 19 | + #[error("Failed to remove dir {0}")] |
| 20 | + RemoveDir(PathBuf, #[source] std::io::Error), |
| 21 | + |
| 22 | + #[error("Failed to parse exercise description at {0}")] |
| 23 | + ParseExerciseDesc(PathBuf, #[source] serde_json::Error), |
| 24 | + #[error("Failed to parse test results at {0}")] |
| 25 | + ParseTestResults(PathBuf, #[source] serde_json::Error), |
| 26 | + |
| 27 | + #[error("Could not locate cache directory")] |
| 28 | + CacheDir, |
| 29 | + #[error("Could not locate boostrap DLL at {0}")] |
| 30 | + MissingBootstrapDll(PathBuf), |
| 31 | + #[error("Error while handling tmc-csharp-runner zip")] |
| 32 | + Zip(#[source] zip::result::ZipError), |
| 33 | + #[error("Failed to run {0}")] |
| 34 | + RunFailed(&'static str, #[source] std::io::Error), |
| 35 | + #[error("Command {0} failed with return code {1}")] |
| 36 | + CommandFailed(&'static str, ExitStatus), |
| 37 | +} |
| 38 | + |
| 39 | +impl From<CSharpError> for TmcError { |
| 40 | + fn from(err: CSharpError) -> Self { |
| 41 | + Self::Plugin(Box::new(err)) |
| 42 | + } |
| 43 | +} |
0 commit comments