Making error reporting compatible with multiple errors

This commit is contained in:
Pavel Shevaev 2023-03-02 18:54:49 +03:00
parent 2ce0a48f03
commit 8839cf79b9
1 changed files with 14 additions and 12 deletions

View File

@ -271,20 +271,22 @@ function bhl_handle_error_result(array $ret_out, $err_file, $exit = true)
exit(1);
}
$err = file_get_contents($err_file);
$jerr = json_decode($err);
if(!$jerr)
$err_lines = file($err_file);
foreach($err_lines as $err)
{
stderr("Something went wrong, bhl error is in invalid format: $err");
if($exit)
exit(1);
}
$file = $jerr->file;
$jerr = json_decode($err);
if(!$jerr)
{
stderr("Something went wrong, bhl error is in invalid format: $err");
continue;
}
stderr("BHL ERROR: \n" . $jerr->error . " \nin '$file', line {$jerr->line}\n");
if(file_exists($file))
stderr(bhl_show_position($jerr->line, $jerr->column, file($file)) . "\n");
if($exit)
$file = $jerr->file;
stderr("BHL ERROR: \n" . $jerr->error . " \nin '$file', line {$jerr->line}\n");
if(file_exists($file))
stderr(bhl_show_position($jerr->line, $jerr->column, file($file)) . "\n");
}
if($err_lines && $exit)
exit(1);
}