public static function get($value, $module, $funcName = NULL, $extraInfo = NULL) { $current_language = Language::getLocale(); Language::setLocale(DEFAULT_LANGUAGE); if (empty($module)) { return PHPWS_Error::get(PHPWS_NO_MODULE, 'core', 'PHPWS_Error::get', 'Value: ' . $value . ', Function: ' . $funcName); } try { $errorFile = PHPWS_Core::getConfigFile($module, 'error.php'); } catch (\Exception $e) { $errorFile = null; } if (empty($errorFile)) { // Error file not found in local config directory. Checking inc/ source directory if ($module == 'core') { $errorFile = PHPWS_SOURCE_DIR . 'core/inc/error.php'; } else { $errorFile = PHPWS_SOURCE_DIR . 'mod/' . $module . '/inc/error.php'; } if (!is_file($errorFile)) { // prevent infinite loop if ($module == 'core') { echo _('Core could not locate its error.php file.'); die; } return PHPWS_Error::get(PHPWS_NO_ERROR_FILE, 'core', 'PHPWS_Error::get', 'Module: ' . $module); } } include $errorFile; if (!isset($errors)) { return FALSE; } if (PHPWS_Error::isError($value)) { $value = $value->getCode(); } if ($module != 'core') { $fullError[] = $module; } else { $fullError[] = 'Core'; } if (isset($funcName)) { $fullError[] = " - {$funcName}()"; } if (isset($errors[$value])) { $message = $errors[$value]; } else { $message = _('Unknown error code.'); } $fullError[] = ' - ' . $message; if (isset($extraInfo)) { if (is_array($extraInfo)) { $message = vsprintf($message, $extraInfo); } else { $fullError[] = ' [' . $extraInfo . ']'; } } $error = PHPWS_Error::raiseError($message, $value, NULL, NULL, implode('', $fullError)); Language::setLocale($current_language); return $error; }