summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ErrorHandler.php3
-rw-r--r--src/ErrorHandlerInterface.php31
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);
+}