mirror of
https://github.com/filp/whoops.git
synced 2026-09-19 06:06:19 +00:00
error-code should be wrapped in ErrorException->severity. fixes #267.
This commit is contained in:
@@ -130,7 +130,8 @@ class PrettyPageHandler extends Handler
|
||||
$code = $inspector->getException()->getCode();
|
||||
|
||||
if ($inspector->getException() instanceof \ErrorException) {
|
||||
$code = Misc::translateErrorCode($code);
|
||||
// ErrorExceptions wrap the php-error types within the "severity" property
|
||||
$code = Misc::translateErrorCode($inspector->getException()->getSeverity());
|
||||
}
|
||||
|
||||
// List of variables that will be passed to the layout template.
|
||||
|
||||
+3
-1
@@ -317,7 +317,9 @@ class Run
|
||||
}
|
||||
}
|
||||
|
||||
$exception = new ErrorException($message, $level, 0, $file, $line);
|
||||
// XXX we pass $level for the "code" param only for BC reasons.
|
||||
// see https://github.com/filp/whoops/issues/267
|
||||
$exception = new ErrorException($message, /*code*/ $level, /*severity*/ $level, $file, $line);
|
||||
if ($this->canThrowExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
|
||||
@@ -364,6 +364,25 @@ class RunTest extends TestCase
|
||||
$this->assertTrue($error && strpos($error['message'], 'strpos()') !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Whoops\Run::handleError
|
||||
* @see https://github.com/filp/whoops/issues/267
|
||||
*/
|
||||
public function testErrorWrappedInException()
|
||||
{
|
||||
try {
|
||||
$run = $this->getRunInstance();
|
||||
$run->handleError(E_WARNING, 'my message', 'my file', 99);
|
||||
$this->fail("missing expected exception");
|
||||
} catch (\ErrorException $e) {
|
||||
$this->assertSame(E_WARNING, $e->getSeverity());
|
||||
$this->assertSame(E_WARNING, $e->getCode(), "For BC reasons getCode() should match getSeverity()");
|
||||
$this->assertSame('my message', $e->getMessage());
|
||||
$this->assertSame('my file', $e->getFile());
|
||||
$this->assertSame(99, $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Whoops\Run::handleException
|
||||
* @covers Whoops\Run::writeToOutput
|
||||
|
||||
Reference in New Issue
Block a user