summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-18 06:30:32 +0000
committerBharat Mediratta <bharat@menalto.com>2009-05-18 06:30:32 +0000
commitad16488643017f293dda6b226024751d15cb4426 (patch)
treecb341549584b0771a255097abf8d9f504035932d /core
parent09d0cd6f01f70b2393f56ea5573af03cb8eb5d87 (diff)
Turn on IN_PRODUCTION mode now across the board. Create our own error
page where we'll show whatever information is useful. Get rid of the IN_PRODUCTION hack in MY_View.php that we no longer need.
Diffstat (limited to 'core')
-rw-r--r--core/libraries/MY_View.php7
-rw-r--r--core/views/kohana_error_page.php118
2 files changed, 119 insertions, 6 deletions
diff --git a/core/libraries/MY_View.php b/core/libraries/MY_View.php
index 15f4d6a4..836d1087 100644
--- a/core/libraries/MY_View.php
+++ b/core/libraries/MY_View.php
@@ -27,7 +27,7 @@ class View extends View_Core {
parent::__construct($name, $data, $type);
$this->set_global("csrf", access::csrf_token());
}
-
+
/**
* Override View_Core::render so that we trap errors stemming from bad PHP includes and show a
* visible stack trace to help developers.
@@ -38,11 +38,6 @@ class View extends View_Core {
try {
return parent::render($print, $renderer);
} catch (Exception $e) {
- if (!IN_PRODUCTION) {
- print $e->getTraceAsString();
- return $e->getMessage();
- }
-
Kohana::Log('error', $e->getTraceAsString());
Kohana::Log('debug', $e->getMessage());
return "";
diff --git a/core/views/kohana_error_page.php b/core/views/kohana_error_page.php
new file mode 100644
index 00000000..83ad5abb
--- /dev/null
+++ b/core/views/kohana_error_page.php
@@ -0,0 +1,118 @@
+<? defined("SYSPATH") or die("No direct script access.") ?>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <style type="text/css">
+ body {
+ background: #fff;
+ font-size: 14px;
+ line-height: 130%;
+ }
+
+ div.big_box {
+ padding: 10px;
+ background: #eee;
+ border: solid 1px #ccc;
+ font-family: sans-serif;
+ color: #111;
+ width: 42em;
+ margin: 20px auto;
+ }
+
+ div#framework_error {
+ text-align: center;
+ }
+
+ div#error_details {
+ text-align: left;
+ }
+
+ code {
+ font-family: monospace;
+ font-size: 12px;
+ margin: 20px;
+ color: #333;
+ white-space: pre-wrap;
+ white-space: -moz-pre-wrap;
+ word-wrap: break-word;
+ }
+
+ h3 {
+ font-family: sans-serif;
+ margin: 2px 0px 0px 0px;
+ padding: 8px 0px 0px 0px;
+ border-top: 1px solid #ddd;
+ }
+
+ p {
+ padding: 0px;
+ margin: 0px 0px 10px 0px;
+ }
+
+ li, pre {
+ padding: 0px;
+ margin: 0px;
+ }
+ </style>
+ <script src="<?= url::file("lib/jquery.js") ?>" type="text/javascript"></script>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <title><?= t("Something went wrong!") ?></title>
+ </head>
+ <body>
+ <? try { $user = user::active(); } catch (Exception $e) { } ?>
+ <? $admin = isset($user) && $user->admin ?>
+ <div class="big_box" id="framework_error">
+ <h1>
+ <?= t("Dang... Something went wrong!") ?>
+ </h1>
+ <h2>
+ <?= t("We tried really hard, but it's broken.") ?>
+ </h2>
+ <? if (!$admin): ?>
+ <p>
+ <?= t("Talk to your Gallery administrator for help fixing this!") ?>
+ </p>
+ <? endif ?>
+ </div>
+ <? if ($admin): ?>
+ <div class="big_box" id="error_details">
+ <h2>
+ <?= t("Hey wait, you're an admin! We can tell you stuff.") ?>
+ </h2>
+ <a id="toggle" href=""
+ onclick="javascript:$('#stuff').slideDown('slow'); $('#toggle').slideUp(); return false">
+ <b><?= t("Ok.. tell me stuff!") ?></b>
+ </a>
+ <div id="stuff" style="display: none">
+ <? if (!empty($line) and !empty($file)): ?>
+ <div id="summary">
+ <h3>
+ <?= t("Help!") ?>
+ </h3>
+ <p>
+ <?= t("If this stuff doesn't make any sense to you, <a href=\"%url\">ask for help in the Gallery forums</a>!", array("url" => "http://gallery.menalto.com/forum/96")) ?>
+ </p>
+ <h3>
+ <?= t("So here's the error:") ?>
+ </h3>
+
+ <code class="block"><?= $message ?></code>
+ <p>
+ <?= t("File: <b>%file</b>, line: <b>%line</b>", array("file" => $file, "line" => $line)) ?>
+ </p>
+ </div>
+ <? endif ?>
+
+ <? $trace = $PHP_ERROR ? array_slice(debug_backtrace(), 1) : $exception->getTrace(); ?>
+ <? $trace = Kohana::backtrace($trace); ?>
+ <? if (!empty($trace)): ?>
+ <div id="stack_trace">
+ <h3>
+ <?= t("And here's how we got there:") ?>
+ </h3>
+ <?= $trace ?>
+ <? endif ?>
+ </div>
+ </div>
+ <? endif ?>
+ </body>
+</html>