Ejemplo n.º 1
0
 static function rescue_exception($exception, $request = null)
 {
     $title = get_class($exception);
     /* activerecord includes the stack trace in the message, so strip it
      * out */
     if ($exception instanceof \ActiveRecord\DatabaseException) {
         $title .= ": " . preg_replace("/\nStack trace:.*/s", "", $exception->getMessage());
     } elseif ($exception->getMessage()) {
         $title .= ": " . $exception->getMessage() . " in " . $exception->getFile() . " on line " . $exception->getLine();
     }
     Rescuer::log_exception($exception, $title, $request);
     Rescuer::notify_of_exception($exception, $title, $request);
     if (php_sapi_name() == "cli") {
         exit(1);
     } else {
         return Rescuer::rescue_in_public($exception, $title, $request);
     }
 }
Ejemplo n.º 2
0
 public function process()
 {
     if (Config::log_level_at_least("short")) {
         register_shutdown_function(array("\\HalfMoon\\Request", "log_runtime"), $this);
     }
     try {
         ob_start();
         Router::instance()->takeRouteForRequest($this);
         /* if we received an If-None-Match header from the client and our
          * generated etag matches it, send a not-modified header and no
          * data */
         if (empty($this->redirected_to) && $this->etag_matches_inm()) {
             $headers = (array) headers_sent();
             ob_end_clean();
             foreach ($headers as $header) {
                 header($header);
             }
             Request::send_status_header(304);
         } else {
             if (empty($this->redirected_to)) {
                 $this->send_etag_header();
             }
             if (ob_get_level()) {
                 ob_end_flush();
             }
         }
     } catch (\Exception $e) {
         /* rescue, log, notify (if necessary), exit */
         if (class_exists("\\HalfMoon\\Rescuer")) {
             Rescuer::rescue_exception($e, $this);
         } else {
             throw $e;
         }
     }
 }