Api‎ > ‎Core‎ > ‎

Fatal

Class RFatal

This class is offers a way to get a handle to fatal errors through the output buffer. Note that fatal errors cannot be trapped. It is useful to log the error and display appropriate output. However PHP will halt once the handler returns. NOTE: This library only works is if display_errors is turned on. If it's turned off, modify php.ini or include: ini_set('display_errors', 'On') before calling setHandler.

Example
<?php 

require_once('RawDev/RawDev.php');
require_once(RAWDEV_LIB.'/Core/Fatal.php');

function fatalErrorHandler($message, $file, $line) {
  return sprintf("nTrapped fatal error [%s] in file [%s] and line [%s].n", $message, $file, $line);
}

#ini_set('display_errors', 'On');
RFatal::setHandler('fatalErrorHandler');

hello(); # since this function does not exist it will throw a fatal error

RFatal::unsetHandler(); # this is optional;

?>

Vars

static callback $handler

The function that is called when a fatal error occurs with the paramers: ($message, $file, $line).

Functions

static void function setHandler($f)

Sets the callback function that is called when a fatal error occurs.

$fcallbackThe function that is called when a fatal error occurs with the paramers: ($message, $file, $line).

static void function restoreHandler()

* Removes the callback function and restores to regular PHP fatal error behavior.

static void function handle($buffer)

* Internal function that is called when the ob buffer is displayed (in normal cases as well as when a fatal error occurs).

$bufferstringThe ob_buffer that is displayed.
Comments