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.