diff --git a/include/library/Crunchbutton/App.php b/include/library/Crunchbutton/App.php index df9e9dc88..a8fc4d1bf 100755 --- a/include/library/Crunchbutton/App.php +++ b/include/library/Crunchbutton/App.php @@ -12,6 +12,7 @@ class Crunchbutton_App extends Cana_App { private $_crypt; public function init($params = null) { + set_exception_handler([$this, 'exception']); if (!$_SERVER['__HTTP_HOST']) { $cli = true; @@ -119,6 +120,31 @@ class Crunchbutton_App extends Cana_App { } + public function exception($e) { + if ($this->env == 'live') { + echo + 'Error'. + '
'. + '

Crunchbutton

'. + '

HEY! Your broke it! No just kidding. There was some sort of error we did not expect. An admin has been notified.

'. + '

Error: '.$e->getMessage(). + '

'; + mail('_EMAIL','CRUNCHBUTTON CRITICAL ERROR',$e->getMessage()); + exit; + } else { + echo "\n
".$e->getMessage()."\n
";
+			foreach($e->getTrace() as $k=>$v){ 
+				if ($v['function'] == "include" || $v['function'] == "include_once" || $v['function'] == "require_once" || $v['function'] == "require"){ 
+					$backtracel .= "#".$k." ".$v['function']."(".$v['args'][0].") called at [".$v['file'].":".$v['line']."]
"; + } else { + $backtracel .= "#".$k." ".$v['function']."() called at [".$v['file'].":".$v['line']."]
"; + } + } + echo $backtracel; + exit; + } + } + public function isCompat() { if (preg_match('/(Firefox\/1\.)|(MSIE (1|2|3|4|5|6|7|8|9))/i',$_SERVER['HTTP_USER_AGENT'])) { return false;