/**
* 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);
    }
}
示例#2
0
 /**
  * rendering content, calls directly SomeDocuemntHTML:render.
  * The rendered content is set to SomeResponse buffer, where it is fetched when output starts.
  * @return void
  *
  */
 public function render()
 {
     $document = SomeFactory::getDocument();
     $document->setTemplate($this->getTemplate());
     $xhtml = $document->render();
     SomeResponse::setBody($xhtml);
     //exit;
 }
示例#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();