code: public function exception(\Exception $ex)
      {
          /** If the current codec cannot encode JSON API, we need to reset it. */
          if ($this->getCodec()->willNotEncode()) {
              $this->codec = $this->api->getDefaultCodec();
          }
  
          return $this->getErrorResponse(
              $this->exceptions->parse($ex)
          );
      }
docs: Render an exception that has arisen from the exception handler.
  
  @param \Exception $ex
  @return mixed