Esempio n. 1
0
 public function body()
 {
     global $dispatch;
     try {
         $dispatch->find_controller_class(array('errorpage'));
         $dispatch->create_controller();
         ob_start();
         $dispatch->render();
         $output = ob_get_clean();
     } catch (Exception $e) {
         lib::log_exception($e);
         # if there are any errors at all, fall back on simple error reporting
         $code = $this->getCode();
         $msg = $this->getMessage();
         $ss = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '';
         $ret = "<html><head><title>{$msg}</title></head><body><h1>{$code}</h1>{$msg}<hr/><em>{$ss}</em></body></html>";
         return $ret;
     }
     return $output;
 }
Esempio n. 2
0
    {
    }
}
try {
    $dispatch = new Dispatch();
    $dispatch->parse_request();
    $dispatch->invoke_form_handler();
    $dispatch->find_controller_class();
    $dispatch->create_controller();
    $dispatch->render();
} catch (HTTPException $e) {
    header("HTTP/1.1 " . $e->getCode() . ' ' . $e->getMessage());
    header("Content-type: text/html");
    if ($loc = $e->location()) {
        header("Location: {$loc}");
    }
    print $e->body();
    print lib::debugbox();
} catch (DataException $e) {
    header("HTTP/1.1 404 Data Exception");
    if ($j = $e->value()) {
        $json = new JSON();
        $j = $json->encode($j);
        header("X-JSON: {$j}");
    }
    print $e->body();
} catch (Exception $e) {
    header("HTTP/1.1 500 Internal Error");
    lib::log_exception($e);
    print lib::debugbox();
}