/** * Error controller * * Render a view for an error code * @param int $file Optional HTTP status */ public static function error($error_code, $reason = NULL) { $errors = Config::get('xysti.errors'); if (isset($errors[$error_code])) { $error = $errors[$error_code]; $error['code'] = $error_code; } else { $error = $errors['generic']; $error['code'] = 'Generic'; } Log::write('error', 'Error ' . $error['code'] . ' at ' . URI::current() . '. ' . $reason); if (View::exists('content.misc.error')) { Xysti::$views['content'] = 'content.misc.error'; Xysti::$data['error'] = $error; } else { Xysti::helper('template'); Xysti::$content = page_title(array('echo' => FALSE, 'title' => $error['title'], 'caption' => $error['code'])) . PHP_EOL . $error['content']; } $view = View::make(Config::get('xysti.template')); if ($error['code'] == 'Generic') { return $view; } else { return Response::make($view, $error['code']); } }