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