Show SystemException's description in AjaxRequest error dialog
authorMatthias Schmidt <gravatronics@live.com>
Thu, 11 Jun 2020 14:15:24 +0000 (16:15 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 11 Jun 2020 14:15:24 +0000 (16:15 +0200)
Close #3365

wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js
wcfsetup/install/files/lib/action/TAJAXException.class.php

index 9dcd6837ecf1940b686cadf99064048b8249ed19..e9fad9cb17cf875b429c21b20548c980c1f45dcc 100644 (file)
@@ -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 += '<br><p>Description:</p><p>' + data.returnValues.description + '</p>';
+                               }
+                               
                                if (data.file && data.line) {
                                        details += '<br><p>File:</p><p>' + data.file + ' in line ' + data.line + '</p>';
                                }
index e8652bff1f87d51c1ff67032b05a733b8f6effc1..a290eafef7f4048bfe3213714d44485a23ceb145 100644 (file)
@@ -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()
                        );