Skip to content

Commit a6f3553

Browse files
authored
fix(laravel): do not normalize exception originalTrace (#6533)
1 parent 5b9767b commit a6f3553

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Laravel/Exception/ErrorHandler.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Negotiation\Negotiator;
3232
use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface;
3333
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface as SymfonyHttpExceptionInterface;
34+
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
3435

3536
class ErrorHandler extends ExceptionsHandler
3637
{
@@ -123,6 +124,17 @@ public function register(): void
123124
} catch (\Exception $e) {
124125
}
125126

127+
$normalizationContext = $operation->getNormalizationContext() ?? [];
128+
if (!($normalizationContext['api_error_resource'] ?? false)) {
129+
$normalizationContext += ['api_error_resource' => true];
130+
}
131+
132+
if (!isset($normalizationContext[AbstractObjectNormalizer::IGNORED_ATTRIBUTES])) {
133+
$normalizationContext[AbstractObjectNormalizer::IGNORED_ATTRIBUTES] = ['trace', 'file', 'line', 'code', 'message', 'originalTrace'];
134+
}
135+
136+
$operation = $operation->withNormalizationContext($normalizationContext);
137+
126138
$dup = $request->duplicate(null, null, []);
127139
$dup->setMethod('GET');
128140
$dup->attributes->set('_api_resource_class', $operation->getClass());

0 commit comments

Comments
 (0)