From 5c06c0870f8e425c2d4ed0f7c330c13e1605628e Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 20 Oct 2020 18:32:46 +0200 Subject: Dislay an error if an exception occurs in the error handler Related to #1598 --- application/front/controller/visitor/ErrorController.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'application/front/controller/visitor/ErrorController.php') diff --git a/application/front/controller/visitor/ErrorController.php b/application/front/controller/visitor/ErrorController.php index 10aa84c8..8da11172 100644 --- a/application/front/controller/visitor/ErrorController.php +++ b/application/front/controller/visitor/ErrorController.php @@ -28,10 +28,7 @@ class ErrorController extends ShaarliVisitorController // Internal error (any other Throwable) if ($this->container->conf->get('dev.debug', false)) { $this->assignView('message', $throwable->getMessage()); - $this->assignView( - 'stacktrace', - nl2br(get_class($throwable) .': '. PHP_EOL . $throwable->getTraceAsString()) - ); + $this->assignView('stacktrace', exception2text($throwable)); } else { $this->assignView('message', t('An unexpected error occurred.')); } -- cgit v1.2.3 From cfdd2094407e61f371c02117c8c66916a6d1d807 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 5 Nov 2020 19:45:41 +0100 Subject: Display error details even with dev.debug set to false It makes more sense to display the error even if it's unexpected. Only for logged in users. Fixes #1606 --- application/front/controller/visitor/ErrorController.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'application/front/controller/visitor/ErrorController.php') diff --git a/application/front/controller/visitor/ErrorController.php b/application/front/controller/visitor/ErrorController.php index 8da11172..428e8254 100644 --- a/application/front/controller/visitor/ErrorController.php +++ b/application/front/controller/visitor/ErrorController.php @@ -26,8 +26,14 @@ class ErrorController extends ShaarliVisitorController $response = $response->withStatus($throwable->getCode()); } else { // Internal error (any other Throwable) - if ($this->container->conf->get('dev.debug', false)) { - $this->assignView('message', $throwable->getMessage()); + if ($this->container->conf->get('dev.debug', false) || $this->container->loginManager->isLoggedIn()) { + $this->assignView('message', t('Error: ') . $throwable->getMessage()); + $this->assignView( + 'text', + '' + . t('Please report it on Github.') + . '' + ); $this->assignView('stacktrace', exception2text($throwable)); } else { $this->assignView('message', t('An unexpected error occurred.')); @@ -36,7 +42,6 @@ class ErrorController extends ShaarliVisitorController $response = $response->withStatus(500); } - return $response->write($this->render('error')); } } -- cgit v1.2.3