diff --git a/cache.inc.php b/cache.inc.php index 741b212..e39daab 100644 --- a/cache.inc.php +++ b/cache.inc.php @@ -201,6 +201,8 @@ class ConfigFetchResult public array $by_path = array(); /** @var array */ public array $by_alias = array(); + /** @var array */ + public array $errors = array(); public int $stales = 0; public int $corruptions = 0; public int $fast_jsons = 0; @@ -233,6 +235,20 @@ function config_cache_fetch(ConfigFetchParams $params) : ConfigFetchResult $result = _config_cache_fetch($params); + if($result->errors) + { + $errors = array(); + foreach($result->errors as $file => $error) + { + $errors[] = (count($errors) + 1) . ") Error in file '$file': $error"; + if(count($errors) > 15) + break; + } + var_dump(sizeof($errors)); + + throw new Exception(implode("\n", $errors)); + } + if($params->verbose) config_log("Fetch from cache: " . round(microtime(true) - $t,2) . " sec."); @@ -306,7 +322,13 @@ function _config_merge_fetch_results(ConfigFetchParams $params, array $results_b { foreach($results as $item) { - list($base_dir, $file, $cache_file, $is_stale, $parser_type) = $item; + list($base_dir, $file, $cache_file, $is_stale, $parser_type, $error) = $item; + + if($error !== null) + { + $result->errors[$file] = $error; + continue; + } if($parser_type === 1) ++$total_fast_jsons; diff --git a/parse.inc.php b/parse.inc.php index dc59f2a..e659452 100644 --- a/parse.inc.php +++ b/parse.inc.php @@ -27,7 +27,7 @@ function config_parse(array $base_dirs, string $file) : ConfigParseResult catch(Exception $e) { $res->error = 1; - $res->error_descr = "File '$file':\n" . $e->getMessage() . "\n" . $e->getTraceAsString(); + $res->error_descr = $e->getMessage() . "\n" . $e->getTraceAsString(); return $res; } diff --git a/task.inc.php b/task.inc.php index c5889d5..0506cbb 100644 --- a/task.inc.php +++ b/task.inc.php @@ -1,6 +1,7 @@ $chunk_data) { + list($base_dir, $file) = $chunk_data; + try { - list($base_dir, $file) = $chunk_data; - if($params->verbose && $file_idx > 0 && ($file_idx % 500) == 0) config_log("Worker $idx progress: " . round($file_idx / sizeof($chunk) * 100) . "% ..."); @@ -78,11 +79,11 @@ function _config_worker_func(ConfigFetchParams $params, array $job) : array if($is_stale) _config_invalidate_cache($params, $base_dir, $file, $cache_file, $parser_type); - $results[] = array($base_dir, $file, $cache_file, $is_stale, $parser_type); + $results[] = array($base_dir, $file, $cache_file, $is_stale, $parser_type, null); } - catch(Exception $e) + catch(Throwable $e) { - throw new Exception("Error in file '$file': " . $e->getMessage()); + $results[] = array($base_dir, $file, null, null, null, $e->getMessage()); } }