protected function getJsonResponseForException(Request $request, Exception $e) { if ($e instanceof HttpException) { if ($e->getStatusCode() == 401) { return $this->unauthorized(); } elseif ($e->getStatusCode() == 404) { return $this->notFound(); } elseif ($e->getStatusCode() < 500) { return $this->badRequest(); } else { return $this->internalError(); } } else { return $this->internalError(); } }