Add Forbidden response

This commit is contained in:
徐哈哈 2019-08-26 16:16:54 +08:00 committed by David Garcia
parent 5cad522151
commit c88f1bc174
3 changed files with 8 additions and 0 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ composer.lock
phpunit.phar
phpunit.xml
modd.conf
.idea

View File

@ -85,6 +85,8 @@ abstract class HttpApi
throw HttpClientException::unauthorized($response);
case 402:
throw HttpClientException::requestFailed($response);
case 403:
throw HttpClientException::forbidden($response);
case 404:
throw HttpClientException::notFound($response);
case 413:

View File

@ -83,6 +83,11 @@ final class HttpClientException extends \RuntimeException implements Exception
return new self('Payload too large, your total attachment size is too big.', 413, $response);
}
public static function forbidden(ResponseInterface $response)
{
return new self('Forbidden', 403, $response);
}
public function getResponse(): ?ResponseInterface
{
return $this->response;