code: protected function prepareJsonApiException(JsonApiException $ex)
      {
          $error = collect($ex->getErrors())->map(function (ErrorInterface $err) {
              return $err->getDetail() ?: $err->getTitle();
          })->filter()->first();
  
          return new HttpException($ex->getHttpCode(), $error, $ex);
      }
docs: Prepare JSON API exception for non-JSON API rendering.
  
  @param JsonApiException $ex
  @return HttpException