sun-times/eh.php

<?php // Error handling

error_reporting(E_ALL | E_STRICT);

function error_handler($errno, $errstr, $errfile, $errline)
{
	exit(json_encode(array
	(
		'success' => FALSE,
		'error' => array
		(
			'code' => $errno,
			'message' => $errstr,
			'file' => $errfile,
			'line' => $errline,
		),
	)));
}
set_error_handler('error_handler');

function exception_handler($e)
{
	exit(json_encode(array
	(
		'success' => FALSE,
		'error' => array
		(
			'code' => $e->getCode(),
			'message' => $e->getMessage(),
			'file' => $e->getFile(),
			'line' => $e->getLine(),
		),
	)));
}
set_exception_handler('exception_handler');