-
Notifications
You must be signed in to change notification settings - Fork 4
/
exception.class.php
56 lines (50 loc) · 1.07 KB
/
exception.class.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
<?php
/**
* Exception class for CPS API
* @package CPS
*/
/**
* Defines
*/
define('ERROR_CODE_INVALID_RESPONSE', 9001);
define('ERROR_CODE_INVALID_PARAMETER', 9002);
define('ERROR_CODE_INVALID_XPATHS', 9003);
define('ERROR_CODE_INVALID_CONNECTION_STRING', 9004);
define('ERROR_CODE_PROTOBUF_ERROR', 9005);
define('ERROR_CODE_SOCKET_ERROR', 9006);
define('ERROR_CODE_TIMEOUT', 9007);
define('ERROR_CODE_NO_WORKING_SERVERS', 9008);
define('ERROR_CODE_SSL_HANDSHAKE', 9009);
define('ERROR_CODE_INVALID_UTF8', 9010);
/**
* Exception class for CPS API
* @package CPS
*/
class CPS_Exception extends Exception {
/**
* Constructor
*/
public function __construct($errors, Exception $previous = null) {
$this->_errors = $errors;
parent::__construct($errors[0]['long_message'], $errors[0]['code'], $previous);
}
/**
* toString
*/
public function __toString() {
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
/**
* code
*/
public function code() {
return $this->code;
}
/**
* errors
*/
public function errors() {
return $this->_errors;
}
private $_errors;
}