Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/ExceptionHandler.php')
-rw-r--r--core/ExceptionHandler.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/ExceptionHandler.php b/core/ExceptionHandler.php
index 6c01785b95..c1f959ce6d 100644
--- a/core/ExceptionHandler.php
+++ b/core/ExceptionHandler.php
@@ -9,10 +9,13 @@
namespace Piwik;
use Exception;
+use Interop\Container\Exception\ContainerException;
use Piwik\API\Request;
use Piwik\API\ResponseBuilder;
use Piwik\Container\ContainerDoesNotExistException;
+use Piwik\Container\StaticContainer;
use Piwik\Plugins\CoreAdminHome\CustomLogo;
+use Psr\Log\LoggerInterface;
/**
* Contains Piwik's uncaught exception handler.
@@ -41,6 +44,8 @@ class ExceptionHandler
*/
public static function dieWithCliError($exception)
{
+ self::logException($exception);
+
$message = $exception->getMessage();
if (!method_exists($exception, 'isHtmlMessage') || !$exception->isHtmlMessage()) {
@@ -65,6 +70,8 @@ class ExceptionHandler
*/
public static function dieWithHtmlErrorPage($exception)
{
+ self::logException($exception);
+
Common::sendHeader('Content-Type: text/html; charset=utf-8');
try {
@@ -137,4 +144,18 @@ class ExceptionHandler
return $result;
}
+
+ private static function logException($exception)
+ {
+ try {
+ StaticContainer::get(LoggerInterface::class)->error('Uncaught exception: {exception}', [
+ 'exception' => $exception,
+ 'ignoreInScreenWriter' => true,
+ ]);
+ } catch (ContainerException $ex) {
+ // ignore (occurs if exception is thrown when resolving DI entries)
+ } catch (ContainerDoesNotExistException $ex) {
+ // ignore
+ }
+ }
}