From 1d757658ff4704f5d3b8cbef4276054129625758 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Mon, 10 Oct 2022 09:47:48 +0300 Subject: [PATCH] Better error messages --- config.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/config.inc.php b/config.inc.php index 849b044..4fb2d75 100644 --- a/config.inc.php +++ b/config.inc.php @@ -394,7 +394,7 @@ function _config_invalidate_cache($file, $cache_file) : ConfigCacheEntry $pres = config_parse(config_base_dir(), $file); if($pres->error !== 0) - throw new Exception("Error({$pres->error}) while loading JSON from {$file}:\n" . $pres->error_descr); + throw new Exception("Error({$pres->error}) while loading JSON in file '{$file}':\n" . $pres->error_descr); $includes = config_get_module_includes($pres->jsm_module); @@ -740,7 +740,7 @@ function config_check_and_decode_jzon($json) function config_load_ex($conf_dir, $file, array $arr, $id = null) { if(!isset($arr['class']) || !isset($arr['class'][0])) - throw new Exception("Class is not set. File '$file'."); + throw new Exception("Class is not set in file '$file'."); $klass = $arr['class']; unset($arr['class']); @@ -751,12 +751,14 @@ function config_load_ex($conf_dir, $file, array $arr, $id = null) $cnf = null; try { + if(!class_exists($klass)) + throw new Exception("No such class '$klass'"); $cnf = new $klass; $cnf->import($arr, true); } catch(Exception $e) { - throw new Exception($e->getMessage() . ". File '{$file}'"/* . $e->getTraceAsString()*/); + throw new Exception($e->getMessage() . " in file '{$file}'"/* . $e->getTraceAsString()*/); } $cnf->id = $id;