Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22aed49

Browse filesBrowse files
committed
[VarDumper] Support ThrownExceptionInformation
1 parent ae5cdc9 commit 22aed49
Copy full SHA for 22aed49

File tree

Expand file treeCollapse file tree

3 files changed

+36
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+36
-0
lines changed

‎src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\VarDumper\Caster;
1313

1414
use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext;
15+
use Symfony\Component\Messenger\Exception\ThrownExceptionDetails;
1516
use Symfony\Component\VarDumper\Cloner\Stub;
1617
use Symfony\Component\VarDumper\Exception\ThrowingCasterException;
1718

@@ -83,6 +84,15 @@ public static function castThrowingCasterException(ThrowingCasterException $e, a
8384
return $a;
8485
}
8586

87+
public static function castThrownExceptionDetails(ThrownExceptionDetails $exceptionDetails, array $a, Stub $stub, bool $isNested, int $filter = 0)
88+
{
89+
$xPrefix = "\0".ThrownExceptionDetails::class."\0";
90+
$stub->class = $exceptionDetails->getClass();
91+
unset($a[$xPrefix.'class']);
92+
93+
return self::filterExceptionArray($exceptionDetails->getClass(), $a, $xPrefix, $filter);
94+
}
95+
8696
public static function castSilencedErrorContext(SilencedErrorContext $e, array $a, Stub $stub, bool $isNested)
8797
{
8898
$sPrefix = "\0".SilencedErrorContext::class."\0";

‎src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ abstract class AbstractCloner implements ClonerInterface
9191
'Symfony\Component\VarDumper\Caster\FrameStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castFrameStub'],
9292
'Symfony\Component\VarDumper\Cloner\AbstractCloner' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
9393
'Symfony\Component\ErrorHandler\Exception\SilencedErrorContext' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castSilencedErrorContext'],
94+
'Symfony\Component\Messenger\Exception\ThrownExceptionDetails' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castThrownExceptionDetails'],
9495

9596
'Imagine\Image\ImageInterface' => ['Symfony\Component\VarDumper\Caster\ImagineCaster', 'castImage'],
9697

‎src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,29 @@ public function testAnonymous()
244244

245245
$this->assertDumpMatchesFormat($expectedDump, $e, Caster::EXCLUDE_VERBOSE);
246246
}
247+
248+
public function testThrownExceptionDetails()
249+
{
250+
$e = \Symfony\Component\ErrorHandler\Exception\FlattenException::createFromThrowable($this->getTestException('foo'));
251+
$exceptionDetails = \Symfony\Component\Messenger\Exception\ThrownExceptionDetails::createFromFlattenException($e);
252+
253+
$expectedDump = <<<'EODUMP'
254+
Exception {
255+
-message: "foo"
256+
-code: 0
257+
-file: "%sExceptionCasterTest.php"
258+
-line: 28
259+
trace: {
260+
%s%eTests%eCaster%eExceptionCasterTest.php:28 {
261+
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
262+
› {
263+
› return new \Exception(''.$msg);
264+
› }
265+
}
266+
%s%eTests%eCaster%eExceptionCasterTest.php:250 { …}
267+
%A
268+
EODUMP;
269+
270+
$this->assertDumpMatchesFormat($expectedDump, $exceptionDetails);
271+
}
247272
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.