original_string: public function handle(
          ServerRequestInterface $request,
          ResponseInterface $response = null,
          $catch = self::DEFAULT_ERROR_CATCH
      )
      {
          /** @var ResponseInterface $response */
          // Passes the request to the container
          if (!$this->getContainer()->has(ServerRequestInterface::class)) {
              $this->getContainer()->share(ServerRequestInterface::class, $request);
          }
  
          //inject request content type
          $contentType = ServerRequestFactory::getHeader('content-type', $this->getRequest()->getHeaders(), '');
          $this->setContentType($contentType);
  
          if ($response === null) {
              $response = $this->getResponse();
          }
  
          $applicationEvent = $this->getApplicationEvent();
          $applicationEvent->setRequest($request);
          $applicationEvent->setResponse($response);
  
          try {
              $response = $this->handleResponse($this->handleRequest($request), $response);
          }catch (\Exception $exception){
              $notFoundException = $exception instanceof NotFoundException;
              $response = $this->handleError($exception, $request, $response, $catch)
                  ->withStatus($notFoundException ? 404 : 500);
          }
  
          // validate response
          $response = $this->validateContract($response, ResponseInterface::class);
  
          // update content type
          $this->setContentType(ServerRequestFactory::getHeader('content-type', $response->getHeaders(), ''));
  
          return $response;
      }
code: public function handle(
          ServerRequestInterface $request,
          ResponseInterface $response = null,
          $catch = self::DEFAULT_ERROR_CATCH
      )
      {
          /** @var ResponseInterface $response */
          // Passes the request to the container
          if (!$this->getContainer()->has(ServerRequestInterface::class)) {
              $this->getContainer()->share(ServerRequestInterface::class, $request);
          }
  
          //inject request content type
          $contentType = ServerRequestFactory::getHeader('content-type', $this->getRequest()->getHeaders(), '');
          $this->setContentType($contentType);
  
          if ($response === null) {
              $response = $this->getResponse();
          }
  
          $applicationEvent = $this->getApplicationEvent();
          $applicationEvent->setRequest($request);
          $applicationEvent->setResponse($response);
  
          try {
              $response = $this->handleResponse($this->handleRequest($request), $response);
          }catch (\Exception $exception){
              $notFoundException = $exception instanceof NotFoundException;
              $response = $this->handleError($exception, $request, $response, $catch)
                  ->withStatus($notFoundException ? 404 : 500);
          }
  
          // validate response
          $response = $this->validateContract($response, ResponseInterface::class);
  
          // update content type
          $this->setContentType(ServerRequestFactory::getHeader('content-type', $response->getHeaders(), ''));
  
          return $response;
      }
code_tokens: public function handle ( ServerRequestInterface $ request , ResponseInterface $ response = null , $ catch = self :: DEFAULT_ERROR_CATCH ) { /** @var ResponseInterface $response */ // Passes the request to the container if ( ! $ this -> getContainer ( ) -> has ( ServerRequestInterface :: class ) ) { $ this -> getContainer ( ) -> share ( ServerRequestInterface :: class , $ request ) ; } //inject request content type $ contentType = ServerRequestFactory :: getHeader ( 'content-type' , $ this -> getRequest ( ) -> getHeaders ( ) , '' ) ; $ this -> setContentType ( $ contentType ) ; if ( $ response === null ) { $ response = $ this -> getResponse ( ) ; } $ applicationEvent = $ this -> getApplicationEvent ( ) ; $ applicationEvent -> setRequest ( $ request ) ; $ applicationEvent -> setResponse ( $ response ) ; try { $ response = $ this -> handleResponse ( $ this -> handleRequest ( $ request ) , $ response ) ; } catch ( \ Exception $ exception ) { $ notFoundException = $ exception instanceof NotFoundException ; $ response = $ this -> handleError ( $ exception , $ request , $ response , $ catch ) -> withStatus ( $ notFoundException ? 404 : 500 ) ; } // validate response $ response = $ this -> validateContract ( $ response , ResponseInterface :: class ) ; // update content type $ this -> setContentType ( ServerRequestFactory :: getHeader ( 'content-type' , $ response -> getHeaders ( ) , '' ) ) ; return $ response ; }
docstring: Convert request into response. If an error occurs, Hawkbit tries
  to handle error as response.
  
  @param ServerRequestInterface $request
  @param ResponseInterface $response
  @param bool $catch
  
  @return ResponseInterface
  
  @throws \Throwable
docstring_tokens: Convert request into response . If an error occurs Hawkbit tries to handle error as response .