Skip to content

Commit

Permalink
Fix severity, file and line in ErrorExceptions
Browse files Browse the repository at this point in the history
Fix `ErrorHandler` only handing an error message to the constructor of
`ErrorException`, but not the severity, file name or line number.
  • Loading branch information
dzuelke committed Jun 25, 2012
1 parent c67cf8b commit 34ab481
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php
Expand Up @@ -64,7 +64,7 @@ public function handle($level, $message, $file, $line, $context)
}

if (error_reporting() & $level && $this->level & $level) {
throw new \ErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line));
throw new \ErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line);
}

return false;
Expand Down
Expand Up @@ -51,6 +51,9 @@ public function testHandle()
$handler->handle(1, 'foo', 'foo.php', 12, 'foo');
} catch (\ErrorException $e) {
$this->assertSame('1: foo in foo.php line 12', $e->getMessage());
$this->assertSame(1, $e->getSeverity());
$this->assertSame('foo.php', $e->getFile());
$this->assertSame(12, $e->getLine());
}

restore_error_handler();
Expand Down

0 comments on commit 34ab481

Please sign in to comment.