Files
gallery3/modules/gallery/views/kohana/error.php
T
Bharat Mediratta 41ca2b0195 Rework our exception framework to fit into Kohana's model better.
Instead of overwriting Kohana_Exception::handle() (which we were doing
in MY_Kohana_Exception) we instead use their existing template system.

gallery/views/kohana/error.php overrides system/views/kohana/error.php
and is the standard error template for all exceptions.  Our version of
error.php figures out the appropriate view based on context (cli,
authenticated admin, guest viewing a 404, guest viewing a system
error) and delegates appropriately.  Each delegated view has a narrow
responsibility.

This paves the way for us to add new error views per module.  For
example, the rest module will define its own template in
Rest_Exception and then its exceptions can be rendered the way that it
wants (json encoded, in that case).
2010-06-19 14:07:32 -07:00

44 lines
1.4 KiB
PHP

<?php defined("SYSPATH") or die("No direct script access.") ?>
<?
// This is the template for all HTML errors. If you're throwing an exception and you want your
// error to appear differently, extend Kohana_Exception and specify a different template.
// Log validation exceptions to ease debugging
if ($e instanceof ORM_Validation_Exception) {
Kohana_Log::add("error", "Validation errors: " . print_r($e->validation->errors(), 1));
}
if (php_sapi_name() == "cli") {
include Kohana::find_file("views", "error_cli.txt");
return;
}
try {
// Admins get a special error page
$user = identity::active_user();
if ($user && $user->admin) {
include Kohana::find_file("views", "error_admin.html");
return;
}
} catch (Exception $ignored) {
}
// Try to show a themed error page for 404 errors
if ($e instanceof Kohana_404_Exception) {
$view = new Theme_View("page.html", "other", "error");
$view->page_title = t("Dang... Page not found!");
$view->content = new View("error_404.html");
$user = identity::active_user();
$view->content->is_guest = $user && $user->guest;
if ($view->content->is_guest) {
$view->content->login_form = new View("login_ajax.html");
$view->content->login_form->form = auth::get_login_form("login/auth_html");
}
print $view;
return;
}
header("HTTP/1.1 500 Internal Server Error");
include Kohana::find_file("views", "error_user.html");
?>