*/ class ExceptionTransformer implements TransformerInterface { /** * Transform the provided exception. * * @param \Exception $exception * * @return \Exception */ public function transform(Exception $exception) { if ($exception instanceof ExceptionInterface) { $exception = new BadRequestHttpException($exception->getMessage()); } elseif ($exception instanceof ModelNotFoundException) { $exception = new NotFoundHttpException('Resource not found.'); } return $exception; } }