Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3918

How with Symfony ExceptionListener return JsonResponse or regular Response depending from used controller?

$
0
0

For example, we have two actions. One return regular Response with rendered twig template, another return JsonResponse.

Both call same method and in this method we throw exception. What i try to achieve - if it is action with twig template - we should get a pretty human readable error message with styles. If it is action with json - we should get json with error message for js frontend.

At this moment i don't found any solution except for example set in ExceptionListener only JsonResponse, and add try-catch in each action with regular response.


Viewing all articles
Browse latest Browse all 3918

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>