Skip to content

Commit

Permalink
Catch DivisionByZeroError on index.php (#2211)
Browse files Browse the repository at this point in the history
Fixes #2204
  • Loading branch information
zackgalbreath committed May 17, 2024
1 parent c1ecdc7 commit c73044c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/cdash/public/api/v1/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,15 @@
if ((int) $build_array['loctesteddiff'] > 0) {
$loctesteddiff = (int) $build_array['loctesteddiff'];
$locuntesteddiff = (int) $build_array['locuntesteddiff'];
@$previouspercent =
round(($loctested - $loctesteddiff) /
($loctested - $loctesteddiff +
$locuntested - $locuntesteddiff)
* 100, 2);
try {
$previouspercent =
round(($loctested - $loctesteddiff) /
($loctested - $loctesteddiff +
$locuntested - $locuntesteddiff)
* 100, 2);
} catch (\DivisionByZeroError $e) {
$previouspercent = 0;
}
$percentdiff = round($percent - $previouspercent, 2);
$coverage_response['percentagediff'] = $percentdiff;
$coverage_response['locuntesteddiff'] = $locuntesteddiff;
Expand Down

0 comments on commit c73044c

Please sign in to comment.