PluginProbe ʕ •ᴥ•ʔ
Image Widget / 4.2
Image Widget v4.2
trunk 1.0 2.0 2.1 2.2 2.2.1 2.2.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.2 3.2.1 3.2.10 3.2.11 3.2.2 3.2.3 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1 4.1.1 4.1.2 4.2 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9
image-widget / freemius / includes / sdk / Exceptions / Exception.php
image-widget / freemius / includes / sdk / Exceptions Last commit date
ArgumentNotExistException.php 10 years ago EmptyArgumentException.php 10 years ago Exception.php 10 years ago InvalidArgumentException.php 10 years ago OAuthException.php 10 years ago
Exception.php
75 lines
1 <?php
2 /**
3 * Thrown when an API call returns an exception.
4 *
5 */
6 class Freemius_Exception extends Exception
7 {
8 protected $_result;
9 protected $_type;
10 protected $_code;
11
12 /**
13 * Make a new API Exception with the given result.
14 *
15 * @param array $result The result from the API server.
16 */
17 public function __construct($result)
18 {
19 $this->_result = $result;
20
21 $code = 0;
22 $message = 'Unknown error, please check GetResult().';
23 $type = '';
24
25 if (isset($result['error']) && is_array($result['error']))
26 {
27 if (isset($result['error']['code']))
28 $code = $result['error']['code'];
29 if (isset($result['error']['message']))
30 $message = $result['error']['message'];
31 if (isset($result['error']['type']))
32 $type = $result['error']['type'];
33 }
34
35 $this->_type = $type;
36 $this->_code = $code;
37
38 parent::__construct($message, is_numeric($code) ? $code : 0);
39 }
40
41 /**
42 * Return the associated result object returned by the API server.
43 *
44 * @return array The result from the API server
45 */
46 public function getResult()
47 {
48 return $this->_result;
49 }
50
51 public function getStringCode()
52 {
53 return $this->_code;
54 }
55
56 public function getType()
57 {
58 return $this->_type;
59 }
60
61 /**
62 * To make debugging easier.
63 *
64 * @return string The string representation of the error
65 */
66 public function __toString()
67 {
68 $str = $this->getType() . ': ';
69
70 if ($this->code != 0)
71 $str .= $this->getStringCode() . ': ';
72
73 return $str . $this->getMessage();
74 }
75 }