diff options
author | Arnold Daniels <arnold@jasny.net> | 2017-01-24 12:27:41 +0100 |
---|---|---|
committer | Arnold Daniels <arnold@jasny.net> | 2017-01-24 12:27:49 +0100 |
commit | 618e5ed7c1639d765eefecf05b72404564c44f8e (patch) | |
tree | 89a96f1e924f2dc6d1e9e607c8cd4ab4daa485ac | |
parent | b78a3c09d7202fb95087c32964a9b97ab3484ac1 (diff) | |
download | error-handler-618e5ed7c1639d765eefecf05b72404564c44f8e.zip error-handler-618e5ed7c1639d765eefecf05b72404564c44f8e.tar.gz error-handler-618e5ed7c1639d765eefecf05b72404564c44f8e.tar.bz2 |
Added ErrorHandlerInterface
-rw-r--r-- | src/ErrorHandler.php | 3 | ||||
-rw-r--r-- | src/ErrorHandlerInterface.php | 31 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/ErrorHandler.php b/src/ErrorHandler.php index 7250b7f..2cf371f 100644 --- a/src/ErrorHandler.php +++ b/src/ErrorHandler.php @@ -9,7 +9,7 @@ use Psr\Log\LoggerAwareInterface; /** * Handle error in following middlewares/app actions */ -class ErrorHandler implements LoggerAwareInterface +class ErrorHandler implements ErrorHandlerInterface, LoggerAwareInterface { use ErrorHandler\Logging; use ErrorHandler\ErrorCodes; @@ -57,7 +57,6 @@ class ErrorHandler implements LoggerAwareInterface } - /** * Use this error handler as middleware */ diff --git a/src/ErrorHandlerInterface.php b/src/ErrorHandlerInterface.php new file mode 100644 index 0000000..0a26e14 --- /dev/null +++ b/src/ErrorHandlerInterface.php @@ -0,0 +1,31 @@ +<?php + +namespace Jasny; + +/** + * Interface for interacting with an error handler. + * The interface is not concerned with how the error handler is configured. + */ +interface ErrorHandlerInterface +{ + /** + * Set the caught error. + * + * @param \Throwable|\Exception|\Error + */ + public function setError($error); + + /** + * Get the caught error. + * + * @return \Throwable|\Exception|\Error + */ + public function getError(); + + /** + * Log an error or exception + * + * @param \Exception|\Error $error + */ + public function log($error); +} |