While rendering an exception, Laravel checks if the exception class has a render() method, if so it just uses the output of this method to build the response, you can return anything from this method as you normally do within a controller method

https://divinglaravel.com/rendering-exceptions?s=09