1 | <?php |
||
9 | class CouldNotSendNotification extends Exception |
||
10 | { |
||
11 | /** |
||
12 | * @param \Psr\Http\Message\ResponseInterface $response |
||
13 | * @return static |
||
14 | */ |
||
15 | public static function serviceRespondedWithAnHttpError(ResponseInterface $response) |
||
16 | { |
||
17 | $message = "Discord responded with an HTTP error: {$response->getStatusCode()}"; |
||
18 | |||
19 | if ($error = Arr::get(json_decode($response->getBody(), true), 'message')) { |
||
20 | $message .= ": $error"; |
||
21 | } |
||
22 | |||
23 | return new static($message); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param array $response |
||
28 | * @return static |
||
29 | */ |
||
30 | public static function serviceRespondedWithAnApiError($response) |
||
34 | |||
35 | /** |
||
36 | * @param \Exception $exception |
||
37 | * @return static |
||
38 | */ |
||
39 | 2 | public static function serviceCommunicationError(Exception $exception) |
|
43 | } |
||
44 |