Skip to content

Commit

Permalink
Style fix: Added the Interface suffix (php-fig#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm authored Sep 5, 2018
1 parent f8cdc8b commit 34722c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions proposed/http-client/http-client-meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ would have a few drawbacks:

### Exception Model

The domain exceptions `NetworkException` and `RequestException` define
The domain exceptions `NetworkExceptionInterface` and `RequestExceptionInterface` define
a contract very similar to each other. The chosen approach is to not let them extend each other
because inheritance does not make sense in the domain model. A `RequestException` is simply not a
`NetworkException`.
because inheritance does not make sense in the domain model. A `RequestExceptionInterface` is simply not a
`NetworkExceptionInterface`.

Allowing exceptions to extend a `RequestAwareException` and/or `ResponseAwareException` interface
has been discussed but that is a convenience shortcut that one should not take. One should rather
catch the specific exceptions and handle them accordingly.

One could be more granular when defining exceptions. For example, `TimeOutException` and `HostNotFoundException`
could be subtypes of `NetworkException`. The chosen approach is not to define such subtypes because
could be subtypes of `NetworkExceptionInterface`. The chosen approach is not to define such subtypes because
the exception handling in a consuming library would in most cases not be different between those exceptions.

#### Throwing exceptions for 4xx and 5xx responses
Expand Down
22 changes: 11 additions & 11 deletions proposed/http-client/http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ body. If the client decodes the body, the client MUST also remove the

### Exceptions

All exceptions thrown by the client MUST implement `Psr\Http\Client\ClientException`.
All exceptions thrown by the client MUST implement `Psr\Http\Client\ClientExceptionInterface`.

When the HTTP client is called with a request that is invalid and cannot be sent, the client
MUST throw a `Psr\Http\Client\RequestException`. If there is an error
MUST throw a `Psr\Http\Client\RequestExceptionInterface`. If there is an error
with the network or the remote server cannot be reached, the HTTP client MUST throw
a `Psr\Http\Client\NetworkException`.
a `Psr\Http\Client\NetworkExceptionInterface`.

Smaller issues that do not block the client from sending the request (such as
invalid HTTP versions) MUST NOT result in exceptions.
Expand Down Expand Up @@ -75,26 +75,26 @@ interface ClientInterface
*
* @return ResponseInterface
*
* @throws \Psr\Http\Client\ClientException If an error happens while processing the request.
* @throws \Psr\Http\Client\ClientExceptionInterface If an error happens while processing the request.
*/
public function sendRequest(RequestInterface $request): ResponseInterface;
}
```

### Exception
### ExceptionInterface

```php
namespace Psr\Http\Client;

/**
* Every HTTP client related Exception MUST implement this interface.
* Every HTTP client related exception MUST implement this interface.
*/
interface ClientException extends \Throwable
interface ClientExceptionInterface extends \Throwable
{
}
```

### RequestException
### RequestExceptionInterface

```php
namespace Psr\Http\Client;
Expand All @@ -108,7 +108,7 @@ use Psr\Http\Message\RequestInterface;
* - Request is invalid (e.g. method is missing)
* - Runtime request errors (e.g. the body stream is not seekable)
*/
interface RequestException extends ClientException
interface RequestExceptionInterface extends ClientExceptionInterface
{
/**
* Returns the request.
Expand All @@ -121,7 +121,7 @@ interface RequestException extends ClientException
}
```

### NetworkException
### NetworkExceptionInterface

```php
namespace Psr\Http\Client;
Expand All @@ -135,7 +135,7 @@ use Psr\Http\Message\RequestInterface;
*
* Example: the target host name can not be resolved or the connection failed.
*/
interface NetworkException extends ClientException
interface NetworkExceptionInterface extends ClientExceptionInterface
{
/**
* Returns the request.
Expand Down

0 comments on commit 34722c6

Please sign in to comment.