forked from milo/github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.php
More file actions
176 lines (128 loc) · 3.05 KB
/
exceptions.php
File metadata and controls
176 lines (128 loc) · 3.05 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/**
* All Milo\Github exceptions at one place. Whole library does not throw anything else.
*
* @author Miloslav Hůla (https://github.com/milo)
*/
namespace Milo\Github {
/**
* Marker interface.
*/
interface IException
{}
/**
* Wrong algorithm. API is used in wrong way. Application code should be changed.
*/
class LogicException extends \LogicException implements IException
{}
/**
* Substitution is used in URL path but corresponding parameter is missing.
*/
class MissingParameterException extends LogicException
{}
/**
* Unpredictable situation occurred.
*/
abstract class RuntimeException extends \RuntimeException implements IException
{}
/**
* Github API returned a non-success HTTP code or data are somehow wrong. See all following descendants.
*
* @see Api::decode()
* @see https://developer.github.com/v3/#client-errors
*/
abstract class ApiException extends RuntimeException
{
/** @var Http\Response|NULL */
private $response;
/**
* @param string
* @param int
*/
public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL)
{
parent::__construct($message, $code, $previous);
$this->response = clone $response;
}
/**
* @return Http\Response|NULL
*/
final public function getResponse()
{
return $this->response;
}
}
/**
* Invalid credentials (e.g. revoked token).
*/
class UnauthorizedException extends ApiException
{}
/**
* Invalid JSON sent to Github API.
*/
class BadRequestException extends ApiException
{}
/**
* Invalid structure sent to Github API (e.g. some required fields are missing).
*/
class UnprocessableEntityException extends ApiException
{}
/**
* Access denied.
* @see https://developer.github.com/v3/#authentication
*/
class ForbiddenException extends ApiException
{}
/**
* Rate limit exceed.
* @see https://developer.github.com/v3/#rate-limiting
*/
class RateLimitExceedException extends ForbiddenException
{}
/**
* Resource not found.
* @see https://developer.github.com/v3/#authentication
*/
class NotFoundException extends ApiException
{}
/**
* Response cannot be classified.
*/
class UnexpectedResponseException extends ApiException
{}
/**
* Response from Github is somehow wrong (e.g. invalid JSON decoding).
*/
class InvalidResponseException extends ApiException
{}
/**
* JSON cannot be decoded, or value cannot be encoded to JSON.
*/
class JsonException extends RuntimeException
{
}
}
namespace Milo\Github\Http {
use Milo\Github;
/**
* HTTP response is somehow wrong and cannot be processed.
*/
class BadResponseException extends Github\RuntimeException
{}
}
namespace Milo\Github\OAuth {
use Milo\Github;
/**
* Something fails during the token obtaining.
*/
class LoginException extends Github\RuntimeException
{}
}
namespace Milo\Github\Storages {
use Milo\Github;
/**
* Directory is missing and/or cannot be created.
*/
class MissingDirectoryException extends Github\RuntimeException
{}
}