UserReportException.php 2.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 4/1/16
 * Time: 11:28 PM
 */

namespace qfq;

require_once(__DIR__ . '/AbstractException.php');

/**
 * Class UserReportException
 *
 * Thrown by Report on User errors
 *
18
19
20
21
22
23
 * Throw with ONE message
 *
 *   throw new UserFormException('Failed: chmod ....', ERROR_IO_CHMOD);
 *
 * Throw with message for User and message for Support.
 *
24
25
26
27
28
  throw new UserFormException(  json_encode(
                                   [ERROR_MESSAGE_TO_USER => 'Failed: chmod',
                                    ERROR_MESSAGE_SUPPORT => "Failed: chmod $mode '$pathFileName'",
                                    ERROR_MESSAGE_HTTP_STATUS => 'HTTP/1.0 409 Bad Request' ]),
                                ERROR_IO_CHMOD);
29
 *
30
31
 * @package qfq\exceptions
 */
32
class UserReportException extends AbstractException {
33

34
    /**
35
36
37
38
39
40
41
42
     * $this->getMessage() might give a) a simple string or b) an JSON String.
     *
     * JSON String: There are 3+1 different messages:
     *   [ERROR_MESSAGE_TO_USER] 'toUser' - shown in the client to the user - no details here!!!
     *   [ERROR_MESSAGE_SUPPORT] 'support' - help for the developer
     *   [ERROR_MESSAGE_OS] 'os' - message from the OS, like 'file not found'
     *
     * @return string HTML formatted error string
43
44
45
46
     * @return string
     * @throws CodeException
     * @throws UserFormException
     */
47
48
    public function formatMessage() {

49
50
51
52
        $this->messageArrayDebug[EXCEPTION_TYPE] = 'User Report Exception';

        $this->messageArrayDebug[EXCEPTION_SQL_RAW] = Store::getVar(SYSTEM_SQL_RAW, STORE_SYSTEM);
        $this->messageArrayDebug[EXCEPTION_SQL_FINAL] = Store::getVar(SYSTEM_SQL_FINAL, STORE_SYSTEM);
53
54
        $this->messageArrayDebug[EXCEPTION_SQL_PARAM_ARRAY] = Store::getVar(SYSTEM_SQL_PARAM_ARRAY, STORE_SYSTEM);

55
56
57
        $this->messageArrayDebug[EXCEPTION_REPORT_COLUMN_INDEX] = Store::getVar(SYSTEM_REPORT_COLUMN_INDEX, STORE_SYSTEM);
        $this->messageArrayDebug[EXCEPTION_REPORT_COLUMN_NAME] = Store::getVar(SYSTEM_REPORT_COLUMN_NAME, STORE_SYSTEM);
        $this->messageArrayDebug[EXCEPTION_REPORT_COLUMN_VALUE] = Store::getVar(SYSTEM_REPORT_COLUMN_VALUE, STORE_SYSTEM);
58
59
60
61

        return parent::formatException();
    }
}