/** * Show an error message to the user and log the error if needed. * Current 404 errors are not logged. This function ends execution. * @param $errNum int the HTTP error code to return, typically 404 for missing page or 500. * @param $info string (optional) with the message to log, not displayed in production. */ public static function showError($errNum, $info = null) { Language::load('Errors'); ob_get_clean(); $defError = Language::tr('500_default_error'); switch ($errNum) { case 404: Error::error404(); die; break; case 500: default: break; } if ($info != null) { Logger::error('[' . $errNum . '] ' . strip_tags($info)); } $data['title'] = Language::tr('500_title'); $data['error'] = $info != null ? Config::SITE_ENVIRONMENT() == 'development' ? $defError . '<br/>' . $info : $defError : $defError; View::addHeader("HTTP/1.0 500 Internal Server Error"); View::renderTemplate('header', $data); View::render('error/500', $data); View::renderTemplate('footer', $data); die; }
/** * on run make an instance of the config class and view class */ public function __construct() { Language::load(str_replace('Controllers\\', '', get_class($this))); }