RequestException.php
1.06 KB
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
<?php
namespace WPML\TM\ATE\API;
/**
* Exception for HTTP requests
*/
class RequestException extends \Exception {
/**
* Type of exception
*
* @var string
*/
protected $type;
/**
* Data associated with the exception
*
* @var mixed
*/
protected $data;
/**
* Create a new exception
*
* @param string $message Exception message.
* @param string|int $type Exception type.
* @param mixed $data Associated data.
* @param int $code Exception numerical code, if applicable.
*/
public function __construct( $message, $type, $data = null, $code = 0 ) {
// Use type as code if code is not set.
// This is for backward compatibility.
$code = 0 === $code ? (int) $type : $code;
parent::__construct( $message, $code );
$this->type = (string) $type;
$this->data = $data;
}
/**
* Like {@see getCode()}, but a string code.
*
* @return string
*/
public function getType() {
return $this->type;
}
/**
* Gives any relevant data
*
* @return mixed
*/
public function getData() {
return $this->data;
}
}