Skip to content

Commit 51904d2

Browse files
feat: Base classes for server and client http exceptions.
Signed-off-by: Johannes Tegnér <johannes@jitesoft.com>
1 parent 60189b6 commit 51904d2

22 files changed

+48
-41
lines changed

src/Http/Client/HttpBadRequestException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpBadRequestException
1413
*
1514
* Client http exception thrown for bad request errors.
1615
*/
17-
class HttpBadRequestException extends HttpException {
16+
class HttpBadRequestException extends HttpClientException {
1817

1918
/**
2019
* HttpBadRequestException constructor.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3+
HttpClientException.php - Part of the php-exceptions project.
4+
5+
© - Jitesoft
6+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7+
namespace Jitesoft\Exceptions\Http\Client;
8+
9+
use Jitesoft\Exceptions\Http\HttpException;
10+
11+
/**
12+
* Base class for HTTP Client Exceptions.
13+
*/
14+
abstract class HttpClientException extends HttpException {}

src/Http/Client/HttpConflictException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
43
HttpConflictException.php - Part of the php-exceptions project.
54
@@ -8,15 +7,14 @@
87

98
namespace Jitesoft\Exceptions\Http\Client;
109

11-
use Jitesoft\Exceptions\Http\HttpException;
1210
use Throwable;
1311

1412
/**
1513
* Class HttpConflictException
1614
*
1715
* Client http exception thrown on http conflict errors.
1816
*/
19-
class HttpConflictException extends HttpException {
17+
class HttpConflictException extends HttpClientException {
2018

2119
/**
2220
* HttpConflictException constructor.

src/Http/Client/HttpExpectationFailedException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpExpectationFailedException
1413
*
1514
* Client http exception thrown when server could not meet the requirements of the `expect` header.
1615
*/
17-
class HttpExpectationFailedException extends HttpException {
16+
class HttpExpectationFailedException extends HttpClientException {
1817

1918
/**
2019
* HttpExpectationFailedException constructor.

src/Http/Client/HttpForbiddenException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpForbiddenException
1413
*
1514
* Client http exception thrown when a forbidden resource.
1615
*/
17-
class HttpForbiddenException extends HttpException {
16+
class HttpForbiddenException extends HttpClientException {
1817

1918
/**
2019
* HttpForbiddenException constructor.

src/Http/Client/HttpGoneException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpGoneException
1413
*
1514
* Client http exception thrown when a resource has been removed and will not be available again.
1615
*/
17-
class HttpGoneException extends HttpException {
16+
class HttpGoneException extends HttpClientException {
1817

1918
/**
2019
* HttpGoneException constructor.

src/Http/Client/HttpImATeapotException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Jitesoft\Exceptions\Http\Server\HttpNotImplementedException;
1110
use Throwable;
1211

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

2322
/**
2423
* HttpImATeapotException constructor.

src/Http/Client/HttpLengthRequiredException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpLengthRequiredException
1413
*
1514
* Client http exception thrown when a content length was not supplied by the client but required by the server.
1615
*/
17-
class HttpLengthRequiredException extends HttpException {
16+
class HttpLengthRequiredException extends HttpClientException {
1817

1918
/**
2019
* HttpLengthRequiredException constructor.

src/Http/Client/HttpMethodNotAllowedException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpMethodNotAllowedException
1413
*
1514
* Client http exception thrown when a request method was not supported for the given resource.
1615
*/
17-
class HttpMethodNotAllowedException extends HttpException {
16+
class HttpMethodNotAllowedException extends HttpClientException {
1817

1918
/**
2019
* HttpMethodNotAllowedException constructor.

src/Http/Client/HttpNotAcceptableException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpNotAcceptableException
1413
*
1514
* Client http exception thrown when the content requested could not be sent due to the client accept header.
1615
*/
17-
class HttpNotAcceptableException extends HttpException {
16+
class HttpNotAcceptableException extends HttpClientException {
1817

1918
/**
2019
* HttpNotAcceptableException constructor.

src/Http/Client/HttpNotFoundException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpNotFoundException
1413
*
1514
* Client http exception thrown when the requested resource was not found.
1615
*/
17-
class HttpNotFoundException extends HttpException {
16+
class HttpNotFoundException extends HttpClientException {
1817

1918
/**
2019
* HttpNotFoundException constructor.

src/Http/Client/HttpRequestTimeoutException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpRequestTimeoutException
1413
*
1514
* Client http exception thrown when the server timed out awaiting an expected client requrest.
1615
*/
17-
class HttpRequestTimeoutException extends HttpException {
16+
class HttpRequestTimeoutException extends HttpClientException {
1817

1918
/**
2019
* HttpRequestTimeoutException constructor.

src/Http/Client/HttpToEarlyException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
@@ -17,7 +16,7 @@
1716
*
1817
* This is an experimental http status code which might change.
1918
*/
20-
class HttpToEarlyException extends HttpException {
19+
class HttpToEarlyException extends HttpClientException {
2120

2221
/**
2322
* HttpToEarlyException constructor.

src/Http/Client/HttpUnauthorizedException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpUnauthorizedException
1413
*
1514
* Client http exception thrown when a resource was requested that the client was not authorized to receive.
1615
*/
17-
class HttpUnauthorizedException extends HttpException {
16+
class HttpUnauthorizedException extends HttpClientException {
1817

1918
/**
2019
* HttpUnauthorizedException constructor.

src/Http/Client/HttpUnavailableForLegalReasonsException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

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

2120
/**

src/Http/Client/HttpUnsupportedMediaTypeException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpUnsupportedMediaTypeException
1413
*
1514
* Client http exception thrown when the request resource or entity have a media type not accepted by the server.
1615
*/
17-
class HttpUnsupportedMediaTypeException extends HttpException {
16+
class HttpUnsupportedMediaTypeException extends HttpClientException {
1817

1918
/**
2019
* HttpUnsupportedMediaTypeException constructor.

src/Http/Client/HttpUpgradeRequiredException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Client;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
@@ -17,7 +16,7 @@
1716
*
1817
* @property string $protocol
1918
*/
20-
class HttpUpgradeRequiredException extends HttpException {
19+
class HttpUpgradeRequiredException extends HttpClientException {
2120
protected string $protocol;
2221

2322
/**

src/Http/Server/HttpBadGatewayException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Server;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
@@ -15,7 +14,7 @@
1514
* Server http exception thrown when the server - working as a gateway - encounters
1615
* an error in the response from the server.
1716
*/
18-
class HttpBadGatewayException extends HttpException {
17+
class HttpBadGatewayException extends HttpServerException {
1918

2019
/**
2120
* HttpBadGatewayException constructor.

src/Http/Server/HttpInternalServerErrorException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Server;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
1312
* Class HttpInternalServerErrorException
1413
*
1514
* Server http exception thrown on internal server errors.
1615
*/
17-
class HttpInternalServerErrorException extends HttpException {
16+
class HttpInternalServerErrorException extends HttpServerException {
1817

1918
/**
2019
* HttpInternalServerErrorException constructor.

src/Http/Server/HttpNotImplementedException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Server;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

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

2019
/**
2120
* HttpNotImplementedException constructor.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3+
HttpServerException.php - Part of the php-exceptions project.
4+
5+
© - Jitesoft
6+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7+
namespace Jitesoft\Exceptions\Http\Server;
8+
9+
use Jitesoft\Exceptions\Http\HttpException;
10+
11+
/**
12+
* Base class for HTTP Server exceptions.
13+
*/
14+
abstract class HttpServerException extends HttpException {}

src/Http/Server/HttpServiceUnavailableException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
77
namespace Jitesoft\Exceptions\Http\Server;
88

9-
use Jitesoft\Exceptions\Http\HttpException;
109
use Throwable;
1110

1211
/**
@@ -17,7 +16,7 @@
1716
* It is recommended to set the retry-after header in the response to allow the client
1817
* to retry the request after the given time.
1918
*/
20-
class HttpServiceUnavailableException extends HttpException {
19+
class HttpServiceUnavailableException extends HttpServerException {
2120
protected ?int $retryAfter;
2221

2322
/**

0 commit comments

Comments
 (0)