Skip to content

Commit

Permalink
clean up error_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Lunzenauer committed Oct 29, 2009
1 parent 378983e commit b2f8475
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
28 changes: 13 additions & 15 deletions lib/src/dispatcher.php
Expand Up @@ -84,8 +84,8 @@ function __construct($trails_root,
*/
function dispatch($uri) {

$old_handler =
set_error_handler(array($this, 'error_handler'), E_ALL);
# E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE|E_RECOVERABLE_ERROR = 5888
$old_handler = set_error_handler(array($this, 'error_handler'), 5888);

ob_start();
$level = ob_get_level();
Expand Down Expand Up @@ -245,23 +245,21 @@ function load_controller($controller) {


/**
* <MethodDescription>
* # TODO (mlunzena) add description
* This method transforms E_USER_* and E_RECOVERABLE_ERROR to
* Trails_Exceptions.
*
* @param type <description>
* @param integer the level of the error raised
* @param string the error message
* @param string the filename that the error was raised in
* @param integer the line number the error was raised at
* @param array an array of every variable that existed in the scope the
* error was triggered in
*
* @return type <description>
* @throws Trails_Exception
*
* @return void
*/
function error_handler($errno, $string, $file, $line, $context) {

if (!($errno & error_reporting())) {
return;
}

if ($errno == E_NOTICE || $errno == E_WARNING || $errno == E_STRICT) {
return FALSE;
}

$e = new Trails_Exception(500, $string);
$e->line = $line;
$e->file = $file;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/response.php
Expand Up @@ -149,7 +149,7 @@ function output() {
*
* @param string the HTTP header
* @param bool optional; TRUE if previously sent header should be
* replaced FALSE otherwise (default)
* replaced - FALSE otherwise (default)
* @param integer optional; the HTTP response code
*
* @return void
Expand Down

0 comments on commit b2f8475

Please sign in to comment.