original_string: private function determineErrorResponse(
          $exception,
          $message,
          ResponseInterface $response,
          ServerRequestInterface $request
      )
      {
          $applicationEvent = $this->getApplicationEvent();
          $applicationEvent->setName(self::EVENT_LIFECYCLE_ERROR);
          $applicationEvent->setRequest($request);
          $applicationEvent->setResponse($response);
          $applicationEvent->setErrorResponse($this->getResponse());
  
          $this->emit($applicationEvent, $exception);
  
          $errorResponse = $applicationEvent->getErrorResponse();
  
          if (!$errorResponse->getBody()->isWritable()) {
              return $errorResponse;
          }
  
          $content = $errorResponse->getBody()->__toString();
          if (empty($content)) {
              $errorResponse->getBody()->write($message);
          }
  
          return $errorResponse;
      }
code: private function determineErrorResponse(
          $exception,
          $message,
          ResponseInterface $response,
          ServerRequestInterface $request
      )
      {
          $applicationEvent = $this->getApplicationEvent();
          $applicationEvent->setName(self::EVENT_LIFECYCLE_ERROR);
          $applicationEvent->setRequest($request);
          $applicationEvent->setResponse($response);
          $applicationEvent->setErrorResponse($this->getResponse());
  
          $this->emit($applicationEvent, $exception);
  
          $errorResponse = $applicationEvent->getErrorResponse();
  
          if (!$errorResponse->getBody()->isWritable()) {
              return $errorResponse;
          }
  
          $content = $errorResponse->getBody()->__toString();
          if (empty($content)) {
              $errorResponse->getBody()->write($message);
          }
  
          return $errorResponse;
      }
code_tokens: private function determineErrorResponse ( $ exception , $ message , ResponseInterface $ response , ServerRequestInterface $ request ) { $ applicationEvent = $ this -> getApplicationEvent ( ) ; $ applicationEvent -> setName ( self :: EVENT_LIFECYCLE_ERROR ) ; $ applicationEvent -> setRequest ( $ request ) ; $ applicationEvent -> setResponse ( $ response ) ; $ applicationEvent -> setErrorResponse ( $ this -> getResponse ( ) ) ; $ this -> emit ( $ applicationEvent , $ exception ) ; $ errorResponse = $ applicationEvent -> getErrorResponse ( ) ; if ( ! $ errorResponse -> getBody ( ) -> isWritable ( ) ) { return $ errorResponse ; } $ content = $ errorResponse -> getBody ( ) -> __toString ( ) ; if ( empty ( $ content ) ) { $ errorResponse -> getBody ( ) -> write ( $ message ) ; } return $ errorResponse ; }
docstring: Determines response for error. Emits `lifecycle.error` event.
  
  @param \Throwable $exception
  @param string $message
  @param ResponseInterface $response
  @param ServerRequestInterface $request
  @return ResponseInterface
docstring_tokens: Determines response for error . Emits lifecycle . error event .