protected function formatException($e, $response)
{
if (!$response->data instanceof \Exception && !$response->data instanceof \Throwable) {
return;
}
if ($e instanceof HttpException) {
$response->status($e->statusCode);
$response->data = $this->exceptionToArray($e);
} else {
if ($this->environment === 'test') {
throw $e;
}
$response->status(500);
$response->data = $this->exceptionToArray($e);
}
}