Skip to content

Commit

Permalink
remove line and file in error_handler\nas the backtrace will contain …
Browse files Browse the repository at this point in the history
…these
  • Loading branch information
Marcus Lunzenauer committed Apr 16, 2010
1 parent 17d7c1b commit 642045b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
7 changes: 2 additions & 5 deletions lib/src/dispatcher.php
Expand Up @@ -146,7 +146,7 @@ function trails_error($exception) {
ob_clean();

# show details for local requests
$detailed = $_SERVER['REMOTE_ADDR'] === '127.0.0.1';
$detailed = @$_SERVER['REMOTE_ADDR'] === '127.0.0.1';

$body = sprintf('<html><head><title>Trails Error</title></head>'.
'<body><h1>%s</h1><pre>%s</pre></body></html>',
Expand Down Expand Up @@ -256,10 +256,7 @@ function load_controller($controller) {
* @return void
*/
function error_handler($errno, $string, $file, $line, $context) {
$e = new Trails_Exception(500, $string);
$e->line = $line;
$e->file = $file;
throw $e;
throw new Trails_Exception(500, $string);
}
}

8 changes: 4 additions & 4 deletions lib/src/exception.php
Expand Up @@ -22,11 +22,11 @@ class Trails_Exception extends Exception {


/**
* <MethodDescription>
*
* @param type <description>
* @param int the status code to be set in the response
* @param string a human readable presentation of the status code
* @param array a hash of additional headers to be set in the response
*
* @return type <description>
* @return void
*/
function __construct($status = 500, $reason = NULL, $headers = array()) {
if ($reason === NULL) {
Expand Down
5 changes: 3 additions & 2 deletions test/lib/dispatcher_test.php
Expand Up @@ -38,7 +38,7 @@ function setUpFS() {
ArrayFileStream::set_filesystem(array(
'app' => array(
'controllers' => array(
'foo.php' => '<?',
'foo.php' => '<?'
),
),
));
Expand All @@ -57,7 +57,7 @@ function test_should_instantiate_controller() {
$this->dispatcher->expectOnce('load_controller', array('foo'));
$this->dispatcher->setReturnValue('load_controller', $controller);
$this->dispatcher->expectOnce('parse');
$this->dispatcher->setReturnValue('parse', array('foo'));
$this->dispatcher->setReturnValue('parse', array('foo', ''));

$result = $this->dispatcher->dispatch("/foo");
}
Expand All @@ -77,3 +77,4 @@ function test_should_throw_an_exception_if_default_controller_could_not_be_found
$dispatcher->dispatch("");
}
}

0 comments on commit 642045b

Please sign in to comment.