Commit 810b81b6 authored by Carsten  Rose's avatar Carsten Rose
Browse files

AbstractException.php: Exception should not use 'Store', if 'Store' can't be instantiated.

parent 6d7b5dc4
......@@ -9,6 +9,7 @@
namespace qfq;
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/UserFormException.php');
class AbstractException extends \Exception {
......@@ -25,7 +26,13 @@ class AbstractException extends \Exception {
*/
public function formatException() {
$debug = '';
$store = Store::getInstance();
try {
// In a very early stage, it might be possible that Store can't be initialized: take care not to use it.
$store = Store::getInstance();
} catch (UserFormException $e) {
$store = null;
}
$html = '';
$this->messageArray['File'] = $this->getFile();
......@@ -33,8 +40,10 @@ class AbstractException extends \Exception {
$this->messageArray['Message'] = $this->getMessage();
$this->messageArray['Code'] = $this->getCode();
$this->messageArray['Stacktrace'] = '<pre>' . $this->getTraceAsString() . '</pre>';
$this->messageArray['Page Id'] = $store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
$this->messageArray['Content Id'] = $store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3);
if ($store !== null) {
$this->messageArray['Page Id'] = $store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
$this->messageArray['Content Id'] = $store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3);
}
$html .= "Code: " . $this->messageArray['Code'] . "<br>";
$html .= "Message: " . Support::wrapTag("<strong>", $this->messageArray['Message']) . "</br>";
......@@ -50,7 +59,7 @@ class AbstractException extends \Exception {
$html = "<h2>Error</h2>" . Support::wrapTag('<p>', $html);
$html = Support::wrapTag("<div class='warning'>", $html);
if ($store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') {
if ($store !== null && $store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') {
// Layout
$debug = '<tr bgcolor="#dddddd"><td colspan="2">Exception</td></tr>';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment