AbstractException.php 1.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/29/16
 * Time: 8:03 AM
 */

namespace qfq;

11
12
require_once(__DIR__ . '/../../qfq/store/Store.php');

13
14
15
16
17
18
19
20
21
22
23
24
25
26

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) {
27
//        $this->store = \qfq\Store::getInstance('');
28
29
30
31
32
33
34
35
36
37
38
39
40
        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();

41
42

        if (Store::getVar('debugShowStack', STORE_TYPO3) === '1') {
43
44
45
46
47
48
            $this->messageArray['Stacktrace'] = '<pre>' . $this->getTraceAsString() . '</pre>';
        }

        // Layout
        $html = '<tr bgcolor="#dddddd"><td colspan="2">Exception</td></tr>';
        foreach ($this->messageArray as $key => $value) {
49
50
51
            if(is_array($value)) {
                $value = var_export($value, true);
            }
52
53
54
55
56
57
58
            $html .= "<tr>" . "<td>$key</td>" . "<td>$value</td>" . "</tr>";
        }

        return "<table border=1>" . $html . "</table>";
    }

}