info->generate($exception, $id, 400); $error = ['id' => $id, 'status' => $info['code'], 'title' => $info['name'], 'detail' => $info['detail'], 'meta' => ['details' => $exception->getMessageBag()->all()]]; return new JsonResponse(['errors' => [$error]], 400, array_merge($headers, ['Content-Type' => $this->contentType()])); } /** * Can we display the exception? * * @param \Exception $original * @param \Exception $transformed * @param int $code * * @return bool */ public function canDisplay(Exception $original, Exception $transformed, $code) { return $transformed instanceof ValidationException; } }