Better error messages

This commit is contained in:
Pavel Shevaev 2022-10-10 09:47:48 +03:00
parent 68e43e49cf
commit 1d757658ff
1 changed files with 5 additions and 3 deletions

View File

@ -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;