code: public function handleException(\Exception $exception)
      {
          if ($this->loggingEnabled) {
              $this->exceptionLogger->log($exception);
          }
  
          if ('cgi' === $this->sapi) {
              $this->header('Status: 500 Internal Server Error');
          } else {
              $this->header('HTTP/1.1 500 Internal Server Error');
          }
  
          $this->writeBody($this->createResponseBody($exception));
      }
docs: handles the exception
  
  @param  \Exception  $exception  the uncatched exception