Exceptions
in package
Provides handling for uncaught exceptions and errors.
Table of Contents
Methods
- convertErrors() : void
- Convert errors to ErrorExceptions.
- handleError() : bool
- Converts errors to ErrorExceptions.
- handleException() : void
- Handles uncaught exceptions.
- handleExceptions() : void
- Handle uncaught exceptions.
- restoreErrors() : void
- Restores error handling to the default PHP state.
- restoreExceptions() : void
- Restores uncaught exception handling to the default PHP state.
Methods
convertErrors()
Convert errors to ErrorExceptions.
public
static convertErrors() : void
Automatically invoked by inclusion of index.php into your project unless the constant NDX_LEAVE_ERRORS
is defined beforehand.
This is not recommended as it may cause undefined behaviour in some classes.
This will also make error suppression not work, luckily you've not been using that since PHP 5. Right? Right?!
Besides, this makes it possible to try..catch errors.
handleError()
Converts errors to ErrorExceptions.
public
static handleError(int $errno, string $errstr, string $errfile, int $errline) : bool
Paramater documentation is copied from the set_error_handler page on php.net
Parameters
- $errno : int
-
The first parameter, errno, will be passed the level of the error raised, as an integer.
- $errstr : string
-
The second parameter, errstr, will be passed the error message, as a string.
- $errfile : string
-
If the callback accepts a third parameter, errfile, it will be passed the filename that the error was raised in, as a string.
- $errline : int
-
If the callback accepts a fourth parameter, errline, it will be passed the line number where the error was raised, as an integer.
Tags
Return values
bool —if this were false the PHP error handler would continue, but returning is never reached.
handleException()
Handles uncaught exceptions.
public
static handleException(Throwable|null $ex) : void
Parameters
- $ex : Throwable|null
-
Uncaught Throwable to handle. May be null to reset state(?) apparently.
Tags
handleExceptions()
Handle uncaught exceptions.
public
static handleExceptions() : void
Automatically invoked by inclusion of index.php into your project unless the constant NDX_LEAVE_EXCEPTIONS
is defined.
restoreErrors()
Restores error handling to the default PHP state.
public
static restoreErrors() : void
restoreExceptions()
Restores uncaught exception handling to the default PHP state.
public
static restoreExceptions() : void