Download the PHP package fp/universal-error-catcher without Composer
On this page you can find all versions of the php package fp/universal-error-catcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fp/universal-error-catcher
More information about fp/universal-error-catcher
Files in fp/universal-error-catcher
Package universal-error-catcher
Short Description Easy way to catch and handle all php errors and exceptions.
License MIT
Homepage https://github.com/formapro/UniversalErrorCatcher
Informations about the package universal-error-catcher
Universal error catcher
Overview
It wraps errors and exception handling logic. Any exceptions or errors (even parse and fatal ones) are handled in the same way.
The lib also provides two custom exceptions:
FatalErrorException
- fatal errors i.e.E_ERROR
,E_PARSE
,E_CORE_ERROR
,E_COMPILE_ERROR
SuppressedErrorException
- recoverable errors which comes from the code under@
It is completely covered with phpunit tests.
Instalation
Composer is a prefered way to install it.
When you are asked for a version constraint, type * and hit enter.
Quick tour
The example shows the simplest way of sanding an email on each error.
Fatal errors.
Let's imagine we try to call a method which does not exist. In this situation php will raise a fatal error.
Or the other situation when we run out of memory. In this case the catcher will gladly free some resorved memory for us.
Recoverable errors:
By default php errors (warnings and so on) wouldn't be thrown but passed to callback in background.
You can change this by converting all errors to exception. just set setThrowRecoverableErrors
to true.
The errors behaind @
(i.e suppressed) are also caught.
Change setThrowSuppressedErrors
to true if you want throw them.
Exceptions:
Any not caught exceptions will be passed to you: