/
Exception.php
91 lines (82 loc) · 2 KB
/
Exception.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* CheddarGetter
* @category CheddarGetter
* @package CheddarGetter
* @author Marc Guyer <marc@cheddargetter.com>
*/
/**
* Response exception object
* @category CheddarGetter
* @package CheddarGetter
* @author Marc Guyer <marc@cheddargetter.com>
* @link http://support.cheddargetter.com/kb/api-8/error-handling
*/
class CheddarGetter_Response_Exception extends Exception {
const REQUEST_INVALID = 400;
const NOT_FOUND = 404;
const PRECONDITION_FAILED = 412;
const UNPROCESSABLE_ENTITY = 422;
const DATA_INVALID = 500;
const USAGE_INVALID = 500;
const UNKNOWN = 500;
/**
* The log id of the error
* @var int|null
*/
protected $id;
/**
* The auxCode of the error
*
* The auxCode is set if the error response contains one.
* It references additional information about the error.
* For more information, see the error handling KB article
* @var string|null
* @link http://support.cheddargetter.com/kb/api-8/error-handling
*/
protected $auxCode;
/**
* Constructor
* @param string|null $message The message from the error response
* @param int $code The error code from the response (http status code)
* @param string|null $id The log id of the error record
* @param string|null $auxCode The auxCode from the error response
*/
public function __construct($message = null, $code = 0, $id = null, $auxCode = null) {
parent::__construct($message, $code);
$this->setId($id);
$this->setAuxCode($auxCode);
}
/**
* Set the error log id
* @param int
* @return CheddarGetter_Response_Exception
*/
public function setId($id) {
$this->id = $id;
return $this;
}
/**
* Set the auxCode
* @param string
* @return CheddarGetter_Response_Exception
*/
public function setAuxCode($auxCode) {
$this->auxCode = $auxCode;
return $this;
}
/**
* Get the error log id
* @return int|null
*/
public function getId() {
return $this->id;
}
/**
* Get the error auxCode
* @return string|null
*/
public function getAuxCode() {
return $this->auxCode;
}
}