Exemplo n.º 1
0
 /**
  * Create's and return's the singleton instance.
  *
  * @return \AppserverIo\Appserver\ServletEngine\Utils\ErrorUtil The singleton instance
  */
 public static function singleton()
 {
     // query whether or not the instance has already been created
     if (ErrorUtil::$instance == null) {
         ErrorUtil::$instance = new ErrorUtil();
     }
     // return the singleton instance
     return ErrorUtil::$instance;
 }
Exemplo n.º 2
0
 /**
  * Does shutdown logic for request handler if something went wrong and
  * produces a fatal error for example.
  *
  * @return void
  */
 public function shutdown()
 {
     // create a local copy of the request/response
     $servletRequest = $this->servletRequest;
     $servletResponse = $this->servletResponse;
     // check if we had a fatal error that caused the shutdown
     if ($lastError = error_get_last()) {
         // add the fatal error
         $this->addError(ErrorUtil::singleton()->fromArray($lastError));
         // in case of fatal errors, we need to override request with perpared
         // instances because error handling needs application access
         $servletRequest = RequestHandler::$requestContext;
     }
     // handle the errors if necessary
     ErrorUtil::singleton()->handleErrors($this, $servletRequest, $servletResponse);
     // copy request/response back to the thread context
     $this->servletRequest = $servletRequest;
     $this->servletResponse = $servletResponse;
 }