From b5af7ce11dcf1c6505639525fdd67b68f3343f44 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 11 Jun 2020 16:15:24 +0200 Subject: [PATCH] Show SystemException's description in AjaxRequest error dialog Close #3365 --- .../files/js/WoltLabSuite/Core/Ajax/Request.js | 4 ++++ .../files/lib/action/TAJAXException.class.php | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js index 9dcd6837ec..e9fad9cb17 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js @@ -314,6 +314,10 @@ define(['Core', 'Language', 'Dom/ChangeListener', 'Dom/Util', 'Ui/Dialog', 'Wolt var message = ''; if (data !== null) { + if (data.returnValues && data.returnValues.description) { + details += '

Description:

' + data.returnValues.description + '

'; + } + if (data.file && data.line) { details += '

File:

' + data.file + ' in line ' + data.line + '

'; } diff --git a/wcfsetup/install/files/lib/action/TAJAXException.class.php b/wcfsetup/install/files/lib/action/TAJAXException.class.php index e8652bff1f..a290eafef7 100644 --- a/wcfsetup/install/files/lib/action/TAJAXException.class.php +++ b/wcfsetup/install/files/lib/action/TAJAXException.class.php @@ -5,6 +5,7 @@ use wcf\system\exception\IllegalLinkException; use wcf\system\exception\InvalidSecurityTokenException; use wcf\system\exception\NamedUserException; use wcf\system\exception\PermissionDeniedException; +use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; use wcf\system\exception\ValidateActionException; use wcf\system\WCF; @@ -99,14 +100,19 @@ trait TAJAXException { ); } else { + $returnValues = [ + 'file' => $e->getFile(), + 'line' => $e->getLine(), + ]; + if ($e instanceof SystemException && $e->getDescription()) { + $returnValues['description'] = $e->getDescription(); + } + throw new AJAXException( $e->getMessage(), AJAXException::INTERNAL_ERROR, $e->getTraceAsString(), - [ - 'file' => $e->getFile(), - 'line' => $e->getLine() - ], + $returnValues, \wcf\functions\exception\logThrowable($e), $e->getPrevious() ); -- 2.20.1