Providing a stacktrace for debugging purpose (will be removed later or at least toggled by some kind of debug switch) and fixed styling (was completely unreadable and messed up).
+/* DEBUG ONLY - DO NOT TOUCH! */
+
+.ui-dialog-title {
+ font-weight: bold !important;
+ text-shadow: 1px 0px 0px rgb(0, 0, 0) !important;
+}
+
+div.ajaxDebugMessage p {
+ border-bottom: 1px solid rgb(192, 192, 192);
+ margin: 0 3px;
+ padding: 7px 0 3px 0;
+}
+
+div.ajaxDebugMessage p:first-child,
+div.ajaxDebugMessage p:last-child {
+ border-bottom-width: 0;
+ margin: 0;
+ padding: 3px;
+}
+
+div.ajaxDebugMessage p:last-child {
+ font-family: Monospace;
+}
/* -- -- -- -- -- EOF -- -- -- -- -- */
}
var $randomID = WCF.getRandomID();
- $('<div id="' + $randomID + '" title="HTTP/1.0 ' + jqXHR.status + ' ' + errorThrown + '"><p>Der Server antwortete: ' + data.message + '.</p></div>').wcfDialog();
+ $('<div class="ajaxDebugMessage" id="' + $randomID + '" title="HTTP/1.0 ' + jqXHR.status + ' ' + errorThrown + '"><p>Der Server antwortete: ' + data.message + '</p><p>Stacktrace:</p><p>' + data.stacktrace + '</p></div>').wcfDialog();
}
// failed to parse JSON
catch (e) {
var $randomID = WCF.getRandomID();
- $('<div id="' + $randomID + '" title="HTTP/1.0 ' + jqXHR.status + ' ' + errorThrown + '"><p>Der Server antwortete: ' + jqXHR.responseText + '.</p></div>').wcfDialog();
+ $('<div class="ajaxDebugMessage" id="' + $randomID + '" title="HTTP/1.0 ' + jqXHR.status + ' ' + errorThrown + '"><p style="padding: 3px;">Der Server antwortete: ' + jqXHR.responseText + '.</p></div>').wcfDialog();
}
this._after();
var $isOpen = this._containers[containerID].data('isOpen');
var $button = $('<img src="' + WCF.Icon.get('wcf.icon.' + ($isOpen ? 'closed' : 'opened')) + '" alt="" />').prependTo(buttonContainer);
$button.data('containerID', containerID).click($.proxy(this._toggleContainer, this));
+
+ return $button;
},
/**
}
});
this._proxy.sendRequest();
+
+ // set spinner for current button
+ this._showSpinner($button);
+ },
+
+ _showSpinner: function(button) {
+ console.debug('Updating icon');
+ button.attr('src', WCF.Icon.get('wcf.icon.loading'));
+ },
+
+ _hideSpinner: function(button, newIcon) {
+ button.attr('src', newIcon);
},
/**
// update container content
this._containerData[$containerID].target.html(data.returnValues.content);
+
+
}
});
<?php
namespace wcf\action;
use wcf\system\exception\AJAXException;
+use wcf\system\exception\SystemException;
use wcf\system\exception\ValidateActionException;
use wcf\util\ArrayUtil;
use wcf\util\ClassUtil;
throw $e;
}
else {
- throw new AJAXException($e->getMessage());
+ throw new AJAXException($e);
}
}
}
// validate class name
if (!class_exists($this->className)) {
- throw new AJAXException("unknown class '".$this->className."'");
+ throw new SystemException("unknown class '".$this->className."'");
}
if (!ClassUtil::isInstanceOf($this->className, 'wcf\data\IDatabaseObjectAction')) {
- throw new AJAXException("'".$this->className."' should implement wcf\system\IDatabaseObjectAction");
+ throw new SystemException("'".$this->className."' should implement wcf\system\IDatabaseObjectAction");
}
// create object action instance
$this->objectAction->validateAction();
}
catch (ValidateActionException $e) {
- throw new AJAXException("validation failed: ".$e->getMessage());
+ throw new SystemException("validation failed: ".$e->getMessage());
}
// execute action
$this->response = $this->objectAction->executeAction();
}
catch (\Exception $e) {
- throw new AJAXException('unknown exception caught: '.$e->getMessage());
+ throw new SystemException('unknown exception caught: '.$e->getMessage());
}
$this->executed();
/**
* Throws a JSON-encoded error message
*
- * @param string $message
+ * @param \Exception $exception
*/
- public function __construct($message) {
+ public function __construct(\Exception $exception) {
+ $stacktrace = $exception->getTraceAsString();
+ if ($exception instanceof SystemException) {
+ $stacktrace = $exception->__getTraceAsString();
+ }
+
//header('HTTP/1.0 418 I\'m a Teapot');
header('HTTP/1.0 503 Service Unavailable');
header('Content-type: application/json');
echo JSON::encode(array(
- 'message' => $message
+ 'message' => $exception->getMessage(),
+ 'stacktrace' => nl2br($stacktrace)
));
exit;
}