mirror of
https://github.com/symfony/http-kernel.git
synced 2026-03-24 01:12:09 +01:00
[Console] fall back to 0 when getCode() does not provide an integer
This commit is contained in:
committed by
Nicolas Grekas
parent
852c1d7401
commit
8e26e05b43
@@ -46,7 +46,7 @@ class ExceptionDataCollector extends DataCollector
|
||||
return $this->data['exception']->getMessage();
|
||||
}
|
||||
|
||||
public function getCode(): int
|
||||
public function getCode(): int|string
|
||||
{
|
||||
return $this->data['exception']->getCode();
|
||||
}
|
||||
|
||||
@@ -36,6 +36,12 @@ class ExceptionDataCollectorTest extends TestCase
|
||||
$this->assertSame(500, $c->getCode());
|
||||
$this->assertSame('exception', $c->getName());
|
||||
$this->assertSame($trace, $c->getTrace());
|
||||
|
||||
$c->collect(new Request(), new Response(), new class() extends \Exception {
|
||||
protected $code = 'non-integer-code';
|
||||
});
|
||||
|
||||
$this->assertSame('non-integer-code', $c->getCode());
|
||||
}
|
||||
|
||||
public function testCollectWithoutException()
|
||||
|
||||
Reference in New Issue
Block a user