public class GenericExceptionHandler

class.errorhandler.php #13

GenericExceptionHandler will handle any uncaught exceptions thrown in Symphony. Additionally, all errors in Symphony that are raised to Exceptions will be handled by this class. It is possible for Exceptions to be caught by their own ExceptionHandler which can override the render function so that it can be displayed to the user appropriately.

Properties

static boolean $enabled

Whether the GenericExceptionHandler should handle exceptions. Defaults to true

Methods

static string|false getTemplate(string $name)

Returns the path to the error-template by looking at the WORKSPACE/template/ directory, then at the TEMPLATES directory for the convention *.tpl. If the template is not found, false is returned

Parameters
  • $name stringName of the template

Returns

String, which is the path to the template if the template is found, false otherwise

static string handler(Throwable $e)

The handler function is given an Throwable and will call it's render function to display the Throwable to a user. After calling the render function, the output is displayed and then exited to prevent any further logic from occurring.

Parameters
Returns

The result of the Throwable's render function

static void initialise(Log $Log)

Initialise will set the error handler to be the __CLASS__::handler function.

Parameters
  • $Log LogAn instance of a Symphony Log object to write errors to

static boolean isValidThrowable(Throwable $e)

This function's goal is to validate the $e parameter in order to ensure that the object is an Exception or a Throwable instance.

Parameters
  • $e ThrowableThe Throwable object that will be validated

Returns

true when valid, false otherwise

static string render(Throwable $e)

The render function will take an Throwable and output a HTML page

Parameters
Returns

An HTML string

static string renderHtml(string $template, string $heading, string $message, string $file, string $line, string $lines, string $trace, string $queries)

This function will fetch the desired $template, and output the Throwable in a user friendly way.

Parameters
  • $template stringThe template name, which should correspond to something in the TEMPLATE directory, eg fatalerror.fatal.

Returns

The HTML of the formatted error message.

static void shutdown()

The shutdown function will capture any fatal errors and format them as a usual Symphony page.

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