diff options
| author | mo8it <mo8it@proton.me> | 2024-04-11 14:39:19 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-11 14:39:19 +0200 |
| commit | f53a0e870045ac0ff1bb4a3be7fe125680d477a5 (patch) | |
| tree | 572f6bc3992e8846cf2e25cc98f833984f2aba6c /src/exercise.rs | |
| parent | 470dc65956dae034f17deefbc0b45490e1ec1448 (diff) | |
Panic if there are no exercises
Diffstat (limited to 'src/exercise.rs')
| -rw-r--r-- | src/exercise.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/exercise.rs b/src/exercise.rs index de435d1..f01c6fc 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -31,12 +31,21 @@ impl InfoFile { pub fn parse() -> Result<Self> { // Read a local `info.toml` if it exists. // Mainly to let the tests work for now. - if let Ok(file_content) = fs::read_to_string("info.toml") { + let slf: Self = if let Ok(file_content) = fs::read_to_string("info.toml") { toml_edit::de::from_str(&file_content) } else { toml_edit::de::from_str(include_str!("../info.toml")) } - .context("Failed to parse `info.toml`") + .context("Failed to parse `info.toml`")?; + + if slf.exercises.is_empty() { + panic!( + "There are no exercises yet! +If you are developing third-party exercises, add at least one exercise before testing." + ); + } + + Ok(slf) } } |
