Api‎ > ‎Core‎ > ‎


Class RErrorReporting

RError traps php errors and throws an exception based on the error. Using Error Reporting will ignore the error_reporting setting and is typically useful in, but not limited to, the development environment environment. The advantage of using this class is (a) that your exception handler also catches php errors and (b) that certain php strict errors thrown and certain ones are ignored. For example, it is generally good to catch undefined variable and object variable references but not undefined indexes and offsets in arrays. RawDev finds that being more strict in variable referencing leads to catching programming mistakes early in the development process.




$b = array();
if ($b[0]); # this will not trigger an error

$difficultVariable = 17;
try {
  if ($difficultVaariable); # this triggers an error because the wrong variable is used.
catch (RException $e) {
  print $e->getMessage()."n";

class Test {

$a = new Test();

try {
  if ($a->b); # this triggers an error because an invalid object variable is used.
catch (RException $e) {
  print $e->getMessage()."n";



static string[] $exceptions

List of messages that should be ignored (strpos is used to see if the string occurs). You can add exceptions to this list

static bool $initialized=false

Whether the error handler is initialized (since this should only happen once).

static int $level

what the maximum error level is that should be handled: 1 = error, 2 = warning, 4 = parse, 8 = notice, 16 = core_error, 32 = core_warning, 64 = compile_error, 128 = compile_warning, 256 = user_error, 512 = user_warning, 1024 = user_notice, 2048 = strict, 4096 = recoverable_error, 8192 = deprecated, 16384 = user_deprecated.


static RErrorReporting function singleton($class) [fluid]

Singleton function that returns a central RErrorReporting class.

$classstringBy default an RErrorError but you could use a derived class

void function initialize() [fluid]

Initializes the error handler.

void function remove()

Removes the error handler.

void function handler($severity, $message, $file, $line)

Handler function that is called when any php error occurs

$severityintSeverity of the error (e.g. error, warning, notice, strict).
$messagestringMessage associated with the error.
$filestringThe file that the error occured in.
$lineintThe line that the error occured in.