UserFormException.php 1.81 KB
Newer Older
1
2
3
4
5
6
7
8
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/1/16
 * Time: 12:43 PM
 */

9

10
namespace qfq;
11

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

14
/**
15
 * Class UserFormException
16
17
18
 *
 * Thrown by Form or FormElement on User errors
 *
19
20
21
22
23
24
 * Throw with ONE message
 *
 *   throw new UserFormException('Failed: chmod ....', ERROR_IO_CHMOD);
 *
 * Throw with message for User and message for Support.
 *
25
26
27
28
29
  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);
30
31
32
 *
 * Call
 *
33
34
 * @package qfq\exceptions
 */
35
class UserFormException extends AbstractException {
36

37
    /**
38
39
40
41
42
43
44
     * $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'
     *
45
46
47
48
     * @return string
     * @throws CodeException
     * @throws UserFormException
     */
49
    public function formatMessage() {
50

51
52
53
54
55
        $this->messageArrayDebug[EXCEPTION_TYPE] = 'User Form Exception';

        $this->messageArrayDebug[EXCEPTION_FORM] = Store::getVar(SYSTEM_FORM, STORE_SYSTEM);
        $this->messageArrayDebug[EXCEPTION_FORM_ELEMENT] = Store::getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM);
        $this->messageArrayDebug[EXCEPTION_FORM_ELEMENT_COLUMN] = Store::getVar(SYSTEM_FORM_ELEMENT_COLUMN, STORE_SYSTEM);
56

57
        return parent::formatException();
58
    }
59
}