Ejemplo n.º 1
0
/**
* error handler set here.
*
* @param int $severity E_XXX codes http://fi2.php.net/manual/en/errorfunc.constants.php
* @param string $message error message
* @param string $filename
* @param int $lineno
*/
function exceptions_error_handler($severity, $message, $filename, $lineno)
{
    if (error_reporting() == 0) {
        return;
    }
    if (error_reporting() & E_NOTICE) {
        //skip notice level errors to avoid everything being an exception
        if (class_exists('SomeResponse')) {
            SomeResponse::setBody("<p class='exception'>{$message} {$filename} {$lineno}</p>");
        }
        //echo "<p>$message $filename $lineno</p>";
        //exit;
        return;
    }
    if (error_reporting() & $severity) {
        SomeResponse::setBody("<p class='exception'>{$message} {$filename} {$lineno}</p>");
        throw new ErrorException($message, 0, $severity, $filename, $lineno);
    }
}
Ejemplo n.º 2
0
 /**
  * method to ut response to browser with headers and body.
  * @return void
  */
 public function close()
 {
     #
     # close cookies, that means send them from SomeCookies. Implement SomeFactory::getSomeCookies() to get instance.
     #
     if (class_exists('SomeCookie')) {
         $cookies = SomeCookie::getInstance();
         $cookies->send();
     }
     SomeResponse::addHeader('Content-Type:text/html; charset=utf-8');
     SomeResponse::send();
     exit;
 }
Ejemplo n.º 3
0
    require_once SOME_LIBRARY . DS . 'some' . DS . 'common.php';
    $framework = SomeFactory::getApplication();
    $debug = $framework->getDebug();
} catch (SomeException $e) {
    //get error template from root and exit, can not even build
    require SOME_PATH . DS . 'error.php';
    exit;
} catch (Exception $e) {
    require SOME_PATH . DS . 'error.php';
    exit;
}
//Try to do framework magic, failing to do so can happen for lots of reasons.
try {
    $app = SomeRequest::getVar('app', 'login');
    $framework->dispatch($app);
    // render puts xhtml string to SomeDocumentHTML buffer, it does not echo anything
    $framework->render();
    // predebug string has all the e_notifications and such messages.
    $prebug = ob_get_clean();
} catch (Exception $e) {
    require SOME_PATH . DS . 'error.php';
    exit;
}
//id debug, echo debug
if ($debug) {
    //echo "<pre>$prebug</pre>\n";
    if ($prebug) {
        SomeResponse::setBody("<pre>{$prebug}</pre>\n");
    }
}
$framework->close();