ErrorHandler
extends ErrorHandlerBase
in package
Class for error handling
Table of Contents
- $ajax : bool
- $back : string
- $debug : bool
- $devel : bool
- $errignore : bool
- $error : bool
- $local : Local
- $senterrors : array<, mixed>
- $wasignored : bool
- $tellfields : mixed
- __construct() : mixed
- Constructor
- assertFail() : void
- Handle an expectation failure
- eIgnore() : bool
- Allow system to ignore errors
- enableDebug() : void
- Put the system into debugging mode
- errorHandler() : bool
- Called when a PHP error is detected - see PHP documentation for details
- exceptionHandler() : void
- Deal with untrapped exceptions - see PHP documentation
- shutdown() : void
- Shutdown function - this is used to catch certain errors that are not otherwise trapped and generate a clean screen as well as an error report to the developers.
- eRewrite() : string
- Rewrite error string
- make500() : void
- Generate a 500 and possibly an error page
- tellAdmin() : string
- Tell sysadmin there was an error
Properties
$ajax
protected
bool
$ajax
= FALSE
$back
protected
string
$back
= ''
Backtrace info - only used with errors
$debug
protected
bool
$debug
= FALSE
$devel
protected
bool
$devel
= FALSE
$errignore
protected
bool
$errignore
= FALSE
If TRUE then ignore trapped errors
$error
protected
bool
$error
= FALSE
If TRUE then we are handling an error
$local
protected
Local
$local
= NULL
$senterrors
protected
array<, mixed>
$senterrors
= []
A list of errors that have been emailed to the user. Only send a message once.
$wasignored
protected
bool
$wasignored
= FALSE
Set to TRUE if an error was trapped and ignored
$tellfields
private
static mixed
$tellfields
= ['REQUEST_URI', 'HTTP_REFERER', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR', 'REQUEST_METHOD', 'REQUEST_SCHEME', 'QUERY_STRING', 'HTTP_COOKIE', 'HTTP_USER_AGENT']
Methods
__construct()
Constructor
public
__construct(bool $devel, bool $ajax, Local $local) : mixed
Parameters
- $devel : bool
- $ajax : bool
- $local : Local
Return values
mixed —assertFail()
Handle an expectation failure
public
assertFail(string $file, int $line, string $message) : void
Parameters
- $file : string
-
File name
- $line : int
-
Line number in file
- $message : string
-
Message
Return values
void —eIgnore()
Allow system to ignore errors
public
eIgnore(bool $ignore) : bool
This always clears the wasignored flag
Parameters
- $ignore : bool
-
If TRUE then ignore the error otherwise stop ignoring
Return values
bool —The last value of the wasignored flag
enableDebug()
Put the system into debugging mode
public
enableDebug() : void
Tags
Return values
void —errorHandler()
Called when a PHP error is detected - see PHP documentation for details
public
errorHandler(int $errno, string $errstr, string $errfile, int $errline) : bool
Note that we can chose to ignore errors. At the moment his is a fairly rough mechanism. It could be made more subtle by allowing the user to specifiy specific errors to ignore. However, exception handling is a much much better way of dealing with this kind of thing whenever possible.
Parameters
- $errno : int
- $errstr : string
- $errfile : string
- $errline : int
Return values
bool —exceptionHandler()
Deal with untrapped exceptions - see PHP documentation
public
exceptionHandler(Throwable $e) : void
Parameters
- $e : Throwable
Return values
void —shutdown()
Shutdown function - this is used to catch certain errors that are not otherwise trapped and generate a clean screen as well as an error report to the developers.
public
shutdown() : void
It also closes the RedBean connection
Return values
void —eRewrite()
Rewrite error string
protected
eRewrite([string $origin = '' ]) : string
Parameters
- $origin : string = ''
-
HTTP details
Return values
string —make500()
Generate a 500 and possibly an error page
protected
make500( $ekey) : void
Parameters
Return values
void —tellAdmin()
Tell sysadmin there was an error
protected
tellAdmin(string $msg, $type, string $file, int $line) : string
Parameters
- $msg : string
-
An error messager
- $type :
-
An error type
- $file : string
-
file in which error happened
- $line : int
-
Line at which it happened