\midcom_exception_handler

Class for intercepting PHP errors and unhandled exceptions. Each fault is caught and converted into Exception handled by midcom_exception_handler::show() with code 500 thus can be customized and make user friendly.

Summary

Methods
Properties
Constants
register()
handle_exception()
handle_error()
show()
get_function_stack()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
send()
_log()
_send_email()
$_exception
N/A

Properties

$_exception

$_exception : \Exception

Holds the current exception

Type

\Exception

Methods

register()

register() 

Register the error and Exception handlers

handle_exception()

handle_exception(  $e) 

Catch an Exception and show it as a HTTP error

Parameters

$e

handle_error()

handle_error(  $errno,   $errstr,   $errfile,   $errline,   $errcontext) 

Catch a PHP error and turn it into an Exception to unify error handling

Parameters

$errno
$errstr
$errfile
$errline
$errcontext

show()

show(integer  $httpcode, string  $message) 

Show an error page.

This will display a simple HTML Page reporting the error described by $httpcode and $message. The $httpcode is also used to send an appropriate HTTP Response.

The error pages can be customized by creating style elements named midcomerror$httpcode.

For a list of the allowed HTTP codes see the MIDCOM_ERR... constants

Note: This function will call _midcom_stop_request() after it is finished.

Parameters

integer $httpcode

The error code to send.

string $message

The message to print.

get_function_stack()

get_function_stack() 

send()

send(integer  $httpcode, string  $message) 

Send error for processing.

If the given error code has an action configured for it, that action will be performed. This means that system administrators can request email notifications of 500 "Internal Errors" and a special log of 404 "Not Founds".

Parameters

integer $httpcode

The error code to send.

string $message

The message to print.

_log()

_log(  $msg, array  $config) 

Parameters

$msg
array $config

_send_email()

_send_email(  $msg, array  $config) 

Parameters

$msg
array $config