Skip to content

Commit 0594ece

Browse files
committedJan 24, 2023
bug #660 Increasing LiveComponentSubscriber ExceptionEvent priority to avoid excess logging (weaverryan)
This PR was merged into the 2.x branch. Discussion ---------- Increasing LiveComponentSubscriber ExceptionEvent priority to avoid excess logging | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | None | License | MIT Hi! If you use the `ComponentWithFormTrait`, when validation fails, a `UnprocessableEntityHttpException` is thrown. This is caught by the `ExceptionEvent` listener on `LiveComponentSubscriber`, which renders the component. It's a very normal, excepted flow. However, currently, the `LiveComponentSubscriber` may run after the core `ErrorListener` as both have a priority of 0. By making our subscriber run first, it avoids unnecessary logging of UnprocessableEntityHttpException by that listener. Caught in the wild on the Symfonycasts code 🎥 Cheers! Commits ------- b75a19e Increasing LiveComponentSubscriber ExceptionEvent priority to avoid unnecessary logging
2 parents 3200460 + b75a19e commit 0594ece

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/LiveComponent/src/EventListener/LiveComponentSubscriber.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ public static function getSubscribedEvents(): array
297297
ControllerEvent::class => 'onKernelController',
298298
ViewEvent::class => 'onKernelView',
299299
ResponseEvent::class => 'onKernelResponse',
300-
ExceptionEvent::class => 'onKernelException',
300+
// priority so that the exception is processed before it can be logged as an error
301+
ExceptionEvent::class => ['onKernelException', 20],
301302
];
302303
}
303304

0 commit comments

Comments
 (0)
Please sign in to comment.