public class GenericErrorHandler

class.errorhandler.php #219

GenericErrorHandler will catch any warnings or notices thrown by PHP and raise the errors to Exceptions so they can be dealt with by the GenericExceptionHandler. If the error raised is not a E_NOTICE or E_STRICT, it will be written to the Symphony log. Symphony will raise Exceptions for errors thrown based on the error_reporting level set in PHP

Properties

static boolean $enabled

Whether the error handler is enabled or not, defaults to true. Setting to false will prevent any Symphony error handling from occurring

static array $errorTypeStrings

An associative array with the PHP error constant as a key, and a string describing that constant as the value

static boolean $logDisabled

Whether to log errors or not. This one is to be used temporarily, e.g., when PHP function is supposed to error out and throw warning and log should be kept clean.

static boolean $raise

Whether to raise all Warnings to Exceptions or not.

Methods

static string handler(integer $code, string $message, string $file, integer $line)

The handler function will write the error to the $Log if it is not E_NOTICE or E_STRICT before raising the error as an Exception. This allows all E_WARNING to actually be captured by an Exception handler.

Parameters
  • $code integerThe error code, one of the PHP error constants

  • $message stringThe message of the error, this will be written to the log and displayed as the exception message

  • $file stringThe file that holds the logic that caused the error. Defaults to null

  • $line integerThe line where the error occurred.

Returns

Usually a string of HTML that will displayed to a user

static void initialise(Log|null $Log, string $raise)

Initialise will set the error handler to be the __CLASS__ handler function and will set this $_Log variable to a Log instance

Parameters
  • $Log Log|null(optional) An instance of a Symphony Log object to write errors to

  • $raise stringWhether to raise E_WARNING as an Exception

static boolean isEnabled()

Determines if the error handler is enabled by checking that error_reporting is set in the php config and that $enabled is true

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details