Skip to content

Commit ba1b03a

Browse files
meisterTvmcj
authored andcommitted
Render contest validation errors more nicely. Fixes #2891
1 parent 86b272b commit ba1b03a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

webapp/src/Service/CheckConfigService.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,16 +472,23 @@ public function checkContestsValidate(): ConfigCheckItem
472472
foreach ($contest->getProblems() as $cp) {
473473
if (empty($cp->getColor())) {
474474
$result = ($result === 'E' ? 'E' : 'W');
475-
$cperrors[$cid] .= "No color for problem " . $cp->getShortname() . " in contest c" . $cid . "\n";
475+
$cperrors[$cid] .= " - No color for problem " . $cp->getShortname() . " in contest c" . $cid . "\n";
476476
}
477477
}
478478
}
479479

480480
$desc = '';
481481
foreach ($contesterrors as $cid => $errors) {
482-
$desc .= "Contest: c$cid: " .
483-
/* @phpstan-ignore-next-line */
484-
(count($errors) == 0 ? 'no errors' : (string)$errors) ."\n" .$cperrors[$cid];
482+
$desc .= "Contest: c$cid: ";
483+
if (count($errors) == 0 && empty($cperrors[$cid])) {
484+
$desc .= "no errors\n";
485+
} else {
486+
$desc .= "errors:\n";
487+
foreach ($errors as $error) {
488+
$desc .= " - " . $error->getPropertyPath() . ": " . $error->getMessage() . "\n";
489+
}
490+
$desc .= $cperrors[$cid];
491+
}
485492
}
486493

487494
$this->stopwatch->stop(__FUNCTION__);

0 commit comments

Comments
 (0)