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); exit(1);
} }
$err = file_get_contents($err_file); $err_lines = file($err_file);
foreach($err_lines as $err)
{
$jerr = json_decode($err); $jerr = json_decode($err);
if(!$jerr) if(!$jerr)
{ {
stderr("Something went wrong, bhl error is in invalid format: $err"); stderr("Something went wrong, bhl error is in invalid format: $err");
if($exit) continue;
exit(1);
} }
$file = $jerr->file;
$file = $jerr->file;
stderr("BHL ERROR: \n" . $jerr->error . " \nin '$file', line {$jerr->line}\n"); stderr("BHL ERROR: \n" . $jerr->error . " \nin '$file', line {$jerr->line}\n");
if(file_exists($file)) if(file_exists($file))
stderr(bhl_show_position($jerr->line, $jerr->column, file($file)) . "\n"); stderr(bhl_show_position($jerr->line, $jerr->column, file($file)) . "\n");
if($exit) }
if($err_lines && $exit)
exit(1); exit(1);
} }