Return response from custom ErrorController without template

I’m trying to catch all the Exceptions on my prefix /api/v1.
I’ve read the book and made this:

config/routes.php
image

src/Controller/Api/V1/ErrorController.php
image

My problem is that if I throw an Exception, the controller displays the template in templates/Error/error500.php even if I use $event->stopPropagation().

Instead, I need to return just the number “1”.
I’ve found a messy workaround which is calling echo “1” and die, but I dont want to do this because I’ve found a content length bigger than 1 on the response header in some servers.

What am I doing wrong? Thanks in advance!