aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_html.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-09-05 01:24:01 +0000
committerrvelices <rv-github@modusoptimus.com>2008-09-05 01:24:01 +0000
commitb8a5fde84629cdc4885016b76c90d9836c4f65b0 (patch)
tree0120912c4862214944e2689c49c44c095f112810 /include/functions_html.inc.php
parent116f1bc4fb9c2825a87d7fab9dbfdde78434431a (diff)
- better management of fatal errors (instead of die or trigger_error rather use fatal_error ...)
git-svn-id: http://piwigo.org/svn/trunk@2502 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions_html.inc.php')
-rw-r--r--include/functions_html.inc.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index ff03675b1..ca07a1e16 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -650,6 +650,44 @@ function page_not_found($msg, $alternate_url=null)
5 );
}
+/**
+ * exits the current script with 500 http code
+ * this method can be called at any time (does not use template/language/user etc...)
+ * @param string msg a message to display
+ */
+function fatal_error($msg)
+{
+ $btrace_msg = '';
+ if (function_exists('debug_backtrace'))
+ {
+ $bt = debug_backtrace();
+ for ($i=1; $i<count($bt); $i++)
+ {
+ $class = isset($bt[$i]['class']) ? (@$bt[$i]['class'].'::') : '';
+ $btrace_msg .= "#$i\t".$class.@$bt[$i]['function'].' '.@$bt[$i]['file']."(".@$bt[$i]['line'].")\n";
+ }
+ $btrace_msg = trim($btrace_msg);
+ $msg .= "\n";
+ }
+
+ $display = "<h1>Piwigo encountered a non recoverable error</h1>
+<pre style='font-size:larger;background:white;color:red;padding:1em;margin:0;clear:both;display:block;width:auto;height:auto;overflow:auto'>
+<b>$msg</b>
+$btrace_msg
+</pre>\n";
+
+ @set_status_header(500);
+ echo $display.str_repeat( ' ', 300); //IE doesn't error output if below a size
+
+ if ( function_exists('ini_set') )
+ {// if possible turn off error display (we display it)
+ ini_set('display_errors', false);
+ }
+ error_reporting( E_ALL );
+ trigger_error( strip_tags($msg).$btrace_msg, E_USER_ERROR );
+ die(0); // just in case
+}
+
/* returns the title to be displayed above thumbnails on tag page
*/
function get_tags_content_title()