Skip to content

Commit

Permalink
feat: Base classes for server and client http exceptions.
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Tegnér <[email protected]>
  • Loading branch information
Johannestegner committed Oct 16, 2023
1 parent 60189b6 commit 51904d2
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 41 deletions.
3 changes: 1 addition & 2 deletions src/Http/Client/HttpBadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpBadRequestException
*
* Client http exception thrown for bad request errors.
*/
class HttpBadRequestException extends HttpException {
class HttpBadRequestException extends HttpClientException {

/**
* HttpBadRequestException constructor.
Expand Down
14 changes: 14 additions & 0 deletions src/Http/Client/HttpClientException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
HttpClientException.php - Part of the php-exceptions project.
© - Jitesoft
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;

/**
* Base class for HTTP Client Exceptions.
*/
abstract class HttpClientException extends HttpException {}
4 changes: 1 addition & 3 deletions src/Http/Client/HttpConflictException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
HttpConflictException.php - Part of the php-exceptions project.
Expand All @@ -8,15 +7,14 @@

namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpConflictException
*
* Client http exception thrown on http conflict errors.
*/
class HttpConflictException extends HttpException {
class HttpConflictException extends HttpClientException {

/**
* HttpConflictException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpExpectationFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpExpectationFailedException
*
* Client http exception thrown when server could not meet the requirements of the `expect` header.
*/
class HttpExpectationFailedException extends HttpException {
class HttpExpectationFailedException extends HttpClientException {

/**
* HttpExpectationFailedException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpForbiddenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpForbiddenException
*
* Client http exception thrown when a forbidden resource.
*/
class HttpForbiddenException extends HttpException {
class HttpForbiddenException extends HttpClientException {

/**
* HttpForbiddenException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpGoneException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpGoneException
*
* Client http exception thrown when a resource has been removed and will not be available again.
*/
class HttpGoneException extends HttpException {
class HttpGoneException extends HttpClientException {

/**
* HttpGoneException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpImATeapotException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Jitesoft\Exceptions\Http\Server\HttpNotImplementedException;
use Throwable;

Expand All @@ -18,7 +17,7 @@
* This is a standardized joke, the http error is sometimes used to indicate that something is not
* fully implemented (in which case @see HttpNotImplementedException would be preferable.
*/
class HttpImATeapotException extends HttpException {
class HttpImATeapotException extends HttpClientException {

/**
* HttpImATeapotException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpLengthRequiredException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpLengthRequiredException
*
* Client http exception thrown when a content length was not supplied by the client but required by the server.
*/
class HttpLengthRequiredException extends HttpException {
class HttpLengthRequiredException extends HttpClientException {

/**
* HttpLengthRequiredException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpMethodNotAllowedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpMethodNotAllowedException
*
* Client http exception thrown when a request method was not supported for the given resource.
*/
class HttpMethodNotAllowedException extends HttpException {
class HttpMethodNotAllowedException extends HttpClientException {

/**
* HttpMethodNotAllowedException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpNotAcceptableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpNotAcceptableException
*
* Client http exception thrown when the content requested could not be sent due to the client accept header.
*/
class HttpNotAcceptableException extends HttpException {
class HttpNotAcceptableException extends HttpClientException {

/**
* HttpNotAcceptableException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpNotFoundException
*
* Client http exception thrown when the requested resource was not found.
*/
class HttpNotFoundException extends HttpException {
class HttpNotFoundException extends HttpClientException {

/**
* HttpNotFoundException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpRequestTimeoutException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpRequestTimeoutException
*
* Client http exception thrown when the server timed out awaiting an expected client requrest.
*/
class HttpRequestTimeoutException extends HttpException {
class HttpRequestTimeoutException extends HttpClientException {

/**
* HttpRequestTimeoutException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpToEarlyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
Expand All @@ -17,7 +16,7 @@
*
* This is an experimental http status code which might change.
*/
class HttpToEarlyException extends HttpException {
class HttpToEarlyException extends HttpClientException {

/**
* HttpToEarlyException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpUnauthorizedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpUnauthorizedException
*
* Client http exception thrown when a resource was requested that the client was not authorized to receive.
*/
class HttpUnauthorizedException extends HttpException {
class HttpUnauthorizedException extends HttpClientException {

/**
* HttpUnauthorizedException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpUnavailableForLegalReasonsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
Expand All @@ -15,7 +14,7 @@
* Client http exception thrown when a requested resource is unavailable
* due to legal reasons hence can't be served.
*/
class HttpUnavailableForLegalReasonsException extends HttpException {
class HttpUnavailableForLegalReasonsException extends HttpClientException {
protected ?string $reason;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpUnsupportedMediaTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpUnsupportedMediaTypeException
*
* Client http exception thrown when the request resource or entity have a media type not accepted by the server.
*/
class HttpUnsupportedMediaTypeException extends HttpException {
class HttpUnsupportedMediaTypeException extends HttpClientException {

/**
* HttpUnsupportedMediaTypeException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Client/HttpUpgradeRequiredException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Client;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
Expand All @@ -17,7 +16,7 @@
*
* @property string $protocol
*/
class HttpUpgradeRequiredException extends HttpException {
class HttpUpgradeRequiredException extends HttpClientException {
protected string $protocol;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Server/HttpBadGatewayException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Server;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
Expand All @@ -15,7 +14,7 @@
* Server http exception thrown when the server - working as a gateway - encounters
* an error in the response from the server.
*/
class HttpBadGatewayException extends HttpException {
class HttpBadGatewayException extends HttpServerException {

/**
* HttpBadGatewayException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Server/HttpInternalServerErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Server;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
* Class HttpInternalServerErrorException
*
* Server http exception thrown on internal server errors.
*/
class HttpInternalServerErrorException extends HttpException {
class HttpInternalServerErrorException extends HttpServerException {

/**
* HttpInternalServerErrorException constructor.
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Server/HttpNotImplementedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Server;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
Expand All @@ -15,7 +14,7 @@
* Server http exception thrown when a requested method or route has not yet been implemented.
* This exception should be used when the request will be implemented later.
*/
class HttpNotImplementedException extends HttpException {
class HttpNotImplementedException extends HttpServerException {

/**
* HttpNotImplementedException constructor.
Expand Down
14 changes: 14 additions & 0 deletions src/Http/Server/HttpServerException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
HttpServerException.php - Part of the php-exceptions project.
© - Jitesoft
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Server;

use Jitesoft\Exceptions\Http\HttpException;

/**
* Base class for HTTP Server exceptions.
*/
abstract class HttpServerException extends HttpException {}
3 changes: 1 addition & 2 deletions src/Http/Server/HttpServiceUnavailableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
namespace Jitesoft\Exceptions\Http\Server;

use Jitesoft\Exceptions\Http\HttpException;
use Throwable;

/**
Expand All @@ -17,7 +16,7 @@
* It is recommended to set the retry-after header in the response to allow the client
* to retry the request after the given time.
*/
class HttpServiceUnavailableException extends HttpException {
class HttpServiceUnavailableException extends HttpServerException {
protected ?int $retryAfter;

/**
Expand Down

0 comments on commit 51904d2

Please sign in to comment.