Commit 845a0fd1 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Exceptions*: Namespace changed to 'qfq'. Implemented AbstractException.

parent da850387
......@@ -9,7 +9,7 @@ namespace qfq;
use qfq;
use qfq\Store;
use qfq\exceptions\UserException;
use qfq\UserException;
use qfq\OnArray;
require_once(__DIR__ . '/../qfq/store/Store.php');
......@@ -96,8 +96,8 @@ abstract class AbstractBuildForm {
/**
* @return string The whole form as HTML
* @throws exceptions\CodeException
* @throws exceptions\DbException
* @throws CodeException
* @throws DbException
*/
public function process() {
......@@ -134,8 +134,8 @@ abstract class AbstractBuildForm {
* @param $recordId
* @param string $filter FORM_ELEMENTS_NATIVE | FORM_ELEMENTS_SUBRECORD | FORM_ELEMENTS_NATIVE_SUBRECORD
* @return string
* @throws exceptions\CodeException
* @throws exceptions\DbException
* @throws CodeException
* @throws DbException
*/
public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0) {
$html = '';
......
......@@ -9,7 +9,7 @@
namespace qfq;
use qfq;
use qfq\exceptions\UserException;
use qfq\UserException;
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/helper/OnArray.php');
......
......@@ -155,6 +155,7 @@ const CLIENT_PHP_SELF = 'PHP_SELF';
const TYPO3_FORM = CLIENT_FORM;
const TYPO3_DEBUG_LOAD = 'debugLoad';
const TYPO3_DEBUG_SAVE = 'debugSave';
const TYPO3_DEBUG_SHOW_STACK = 'debugShowStack';
const TYPO3_FE_USER = 'feUser';
const TYPO3_FE_USER_UID = 'feUserUid';
const TYPO3_FE_USER_GROUP = 'feUserGroup';
......
......@@ -10,9 +10,9 @@ namespace qfq;
use qfq;
use qfq\Store;
use qfq\exceptions\CodeException;
use qfq\exceptions\UserException;
use qfq\exceptions\DbException;
use qfq\CodeException;
use qfq\UserException;
use qfq\DbException;
require_once(__DIR__ . '/../qfq/exceptions/UserException.php');
......@@ -97,7 +97,7 @@ class Database {
* @param string $table name of the table
* @param string $columnName name of the column
*
* @throws exceptions\UserException if the table or column does not exist, or is not of type ENUM or SET
* @throws UserException if the table or column does not exist, or is not of type ENUM or SET
* @return array
*/
public function getEnumSetValueList($table, $columnName) {
......@@ -135,7 +135,7 @@ class Database {
*
* @return array the definition of the column as retrieved by Database::getTableDefinition().
*
* @throws exceptions\UserException
* @throws UserException
*
*/
private function getFieldDefinitionFromTable($table, $columnName) {
......
......@@ -65,12 +65,12 @@ class Evaluate {
* @param $line
* @param int $recursion
* @return array|mixed|null|string
* @throws exceptions\UserException
* @throws UserException
*/
public function parse($line, $recursion = 0) {
if ($recursion > 4) {
throw new qfq\exceptions\UserException("Recursion too deep: $line", ERROR_RECURSION_TOO_DEEP);
throw new qfq\UserException("Recursion too deep: $line", ERROR_RECURSION_TOO_DEEP);
}
$posFirstClose = strpos($line, $this->endDelimiter);
......@@ -81,7 +81,7 @@ class Evaluate {
$posMatchOpen = strrpos(substr($line, 0, $posFirstClose), $this->startDelimiter);
if ($posMatchOpen === false) {
throw new \qfq\exceptions\UserException("Missing open delimiter: $line", ERROR_MISSING_OPEN_DELIMITER);
throw new \qfq\UserException("Missing open delimiter: $line", ERROR_MISSING_OPEN_DELIMITER);
}
$pre = substr($line, 0, $posMatchOpen);
......@@ -119,7 +119,7 @@ class Evaluate {
*
* @param $token
* @return array|mixed|null|string
* @throws exceptions\DbException
* @throws DbException
*/
public function substitute($token) {
$sqlMode = ROW_IMPLODE_ALL;
......
......@@ -13,9 +13,9 @@ use qfq;
use qfq\BuildFormPlain;
use qfq\BuildFormTable;
use qfq\BuildFormBootstrap;
use qfq\exceptions\UserException;
use qfq\exceptions\CodeException;
use qfq\exceptions\DbException;
use qfq\UserException;
use qfq\CodeException;
use qfq\DbException;
//use qfq\helper;
use qfq\Store;
......@@ -199,7 +199,7 @@ class Form {
/**
* @return string
* @throws UserException
* @throws exceptions\CodeException
* @throws CodeException
*/
private function getFormName() {
......
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 1/29/16
* Time: 8:03 AM
*/
namespace qfq;
class AbstractException extends \Exception {
public $messageArray = array();
public $store;
/**
* Constructor
*
* @param string $message
* @param int $code
* @param \Exception $previous
*/
public function __construct($message = '', $code = 0, \Exception $previous = null) {
$this->store = \qfq\Store::getInstance('');
parent::__construct($message, $code, $previous);
}
/**
* @return string
*/
public function formatException() {
$this->messageArray['File'] = $this->getFile();
$this->messageArray['Line'] = $this->getLine();
$this->messageArray['Message'] = $this->getMessage();
$this->messageArray['Code'] = $this->getCode();
if ($this->store->getVar('debugShowStack', STORE_TYPO3) === '1') {
$this->messageArray['Stacktrace'] = '<pre>' . $this->getTraceAsString() . '</pre>';
}
// Layout
$html = '<tr bgcolor="#dddddd"><td colspan="2">Exception</td></tr>';
foreach ($this->messageArray as $key => $value) {
$html .= "<tr>" . "<td>$key</td>" . "<td>$value</td>" . "</tr>";
}
return "<table border=1>" . $html . "</table>";
}
}
\ No newline at end of file
......@@ -6,9 +6,9 @@
* Time: 12:43 PM
*/
namespace qfq\exceptions;
namespace qfq;
use qfq\Store;
require_once(__DIR__ . '/AbstractException.php');
/**
* Class UserException
......@@ -17,23 +17,15 @@ use qfq\Store;
*
* @package qfq\exceptions
*/
class CodeException extends \Exception {
class CodeException extends AbstractException {
/*
* @return string HTML formatted error string
*/
* @return string HTML formatted error string
*/
public function formatMessage() {
$message = '<table border="1">';
$message .= '<tr bgcolor="#dddddd"><td>Action</td><td>Code Exception</td></tr>' ;
$message .= '<tr bgcolor="#dddddd"><td>File</td><td>'. $this->getFile(). '</td></tr>' ;
$message .= '<tr bgcolor="#dddddd"><td>Line</td><td>'. $this->getLine(). '</td></tr>' ;
$message .= '<tr bgcolor="#dddddd"><td>Message</td><td>'. $this->getMessage(). '</td></tr>' ;
$message .= '<tr bgcolor="#dddddd"><td>Code</td><td>'. $this->getCode(). '</td></tr>' ;
$message .= '<tr bgcolor="#dddddd"><td>Stacktrace</td><td>'. str_replace("\n", "<br>", $this->getTraceAsString()). '</td></tr>' ;
$message .= '</table>';
$this->messageArray['Type'] = 'Code Exception';
return($message);
return parent::formatException();
}
}
\ No newline at end of file
......@@ -7,12 +7,9 @@
*/
namespace qfq\exceptions;
namespace qfq;
use qfq\Store;
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/AbstractException.php');
/**
* Class UserException
......@@ -21,26 +18,22 @@ require_once(__DIR__ . '/../../qfq/Constants.php');
*
* @package qfq\exceptions
*/
class DbException extends \Exception {
class DbException extends AbstractException {
/*
* @return string HTML formatted error string
*/
public function formatMessage() {
$store = Store::getInstance('');
$message = '<table border=1><tr><th>DB Exception</th></tr>' .
'<tr><td>Message</td><td><b>' . $this->getMessage() . '</b></td></tr>' .
'<tr><td>Code</td><td><b>' . $this->getCode() . '</b></td></tr>' .
'<tr><td>Form</td><td>' . $store->getVar(SYSTEM_FORM, STORE_SYSTEM) . '</td></tr>' .
'<tr><td>Form Element</td><td>' . $store->getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM) . '</td></tr>' .
'<tr><td>Form Element Column</td><td>' . $store->getVar(SYSTEM_FORM_ELEMENT_COLUMN, STORE_SYSTEM) . '</td></tr>' .
'<tr><td>SQL before evaluation</td><td>' . $store->getVar(SYSTEM_SQL_RAW, STORE_SYSTEM) . '</td></tr>' .
'<tr><td>SQL after evaluation</td><td>' . $store->getVar(SYSTEM_SQL_FINAL, STORE_SYSTEM) . '</td></tr>' .
'<tr><td>SQL Params</td><td>' . str_replace("\n", "<br>", print_r($store->getVar(SYSTEM_SQL_PARAM_ARRAY, STORE_SYSTEM), true)) . '</td></tr>' .
'<tr bgcolor="#dddddd"><td>Stacktrace</td><td>'. str_replace("\n", "<br>", $this->getTraceAsString()). '</td></tr>' .
'</table>';
return ($message);
$this->messageArray['Type'] = 'Db Exception';
$this->messageArray['Form'] = $this->store->getVar(SYSTEM_FORM, STORE_SYSTEM);
$this->messageArray['Form Element'] = $this->store->getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM);
$this->messageArray['Form Element Column'] = $this->store->getVar(SYSTEM_FORM_ELEMENT_COLUMN, STORE_SYSTEM);
$this->messageArray['SQL before evaluation'] = $this->store->getVar(SYSTEM_SQL_RAW, STORE_SYSTEM);
$this->messageArray['SQL after evaluation'] = $this->store->getVar(SYSTEM_SQL_FINAL, STORE_SYSTEM);
$this->messageArray['SQL Params'] = $this->store->getVar(SYSTEM_SQL_PARAM_ARRAY, STORE_SYSTEM);
return parent::formatException();
}
}
......@@ -7,12 +7,9 @@
*/
namespace qfq\exceptions;
namespace qfq;
use qfq\Store;
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/AbstractException.php');
/**
* Class UserException
......@@ -21,24 +18,18 @@ require_once(__DIR__ . '/../../qfq/Constants.php');
*
* @package qfq\exceptions
*/
class UserException extends \Exception {
class UserException extends AbstractException {
/*
* @return string HTML formatted error string
*/
public function formatMessage() {
$store = \qfq\Store::getInstance('');
$message = '<table border=1><tr><th>User Exception</th></tr>' .
'<tr><td>Message</td><td><b>' . $this->getMessage() . '</b></td></tr>' .
'<tr><td>Code</td><td><b>' . $this->getCode() . '</b></td></tr>' .
'<tr><td>Form</td><td>' . $store->getVar(SYSTEM_FORM, STORE_SYSTEM) . '</td></tr>' .
'<tr><td>Form Element</td><td>' . $store->getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM) . '</td></tr>' .
'<tr><td>Form Element Column</td><td>' . $store->getVar(SYSTEM_FORM_ELEMENT_COLUMN, STORE_SYSTEM) . '</td></tr>' .
'<tr bgcolor="#dddddd"><td>Stacktrace</td><td>'. str_replace("\n", "<br>", $this->getTraceAsString()). '</td></tr>' .
'</table>';
$this->messageArray['Type'] = 'User Exception';
$this->messageArray['Form'] = $this->store->getVar(SYSTEM_FORM, STORE_SYSTEM);
$this->messageArray['Form Element'] = $this->store->getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM);
$this->messageArray['Form Element Column'] = $this->store->getVar(SYSTEM_FORM_ELEMENT_COLUMN, STORE_SYSTEM);
return ($message);
return parent::formatException();
}
}
......@@ -10,7 +10,7 @@ namespace qfq;
use qfq;
use qfq\Store;
use qfq\exceptions\UserException;
use qfq\UserException;
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
......
......@@ -11,7 +11,7 @@
namespace qfq;
use qfq;
use qfq\exceptions\UserException;
use qfq\UserException;
require_once(__DIR__ . '/../exceptions/UserException.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
......
......@@ -9,7 +9,7 @@
namespace qfq;
use qfq;
use qfq\exceptions\CodeException;
use qfq\CodeException;
require_once(__DIR__ . '/../../qfq/Constants.php');
......
......@@ -14,7 +14,7 @@ class Support {
/**
* @return string If exist content of $_GET[], otherwise the name of the first GET Parameter
* @throws exceptions\CodeException
* @throws CodeException
*/
public static function getCurrentPage() {
if (isset($_GET['id'])) {
......
......@@ -8,8 +8,8 @@
namespace qfq;
use qfq\exceptions\CodeException;
use qfq\exceptions\UserException;
use qfq\CodeException;
use qfq\UserException;
use qfq\OnArray;
use qfq\KeyValueStringParser;
......@@ -206,7 +206,7 @@ class Sip {
* @param $s
* @return array Parameter Array
* @throws UserException
* @throws \qfq\exceptions\UserException
* @throws \qfq\UserException
*/
public function getVarsFromSip($s) {
......
......@@ -8,7 +8,7 @@
namespace qfq;
use qfq\exceptions\CodeException;
use qfq\CodeException;
use qfq\keyValueStringParser;
use qfq\OnArray;
use qfq;
......@@ -152,13 +152,13 @@ class Store {
/**
* @throws CodeException
* @throws qfq\exceptions\UserException
* @throws qfq\UserException
*/
private function fillSystemStore() {
try {
$config = parse_ini_file(QFQ_INI, false);
} catch (\Exception $e) {
throw new qfq\exceptions\UserException ("Error read file " . QFQ_INI . ": " . $e->getMessage(), ERROR_READ_FILE);
throw new qfq\UserException ("Error read file " . QFQ_INI . ": " . $e->getMessage(), ERROR_READ_FILE);
}
self::setVarArray($config, STORE_SYSTEM);
}
......@@ -220,7 +220,7 @@ class Store {
/**
* @throws CodeException
* @throws exceptions\UserException
* @throws UserException
*/
private function fillStoreSip() {
......
Markdown is supported
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