diff --git a/bhl.inc.php b/bhl.inc.php index b6861cb..2b45bdf 100644 --- a/bhl.inc.php +++ b/bhl.inc.php @@ -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); }