blob: efd1a867eda4f1ecd97518d9e6e0ac504bc17ae8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
declare(strict_types=1);
namespace Cepis;
/**
* Implemented by every exception this library throws. Catch it to handle any
* failure with one handler.
*
* It is an interface rather than a base class so that each concrete exception
* can also extend the SPL type a PHP developer would already be catching:
* {@see InvalidCepException} is an `\InvalidArgumentException`, so code that
* already validates input keeps working without knowing this library exists,
* and {@see CepNotFoundException} is an `\OutOfBoundsException`, because
* looking a CEP up is conceptually a key lookup. PHP has single inheritance;
* a marker interface is the only way to have both.
*
* Below this interface the split is by **the decision the caller has to
* make**, not by the HTTP status that caused it:
*
* - {@see InvalidCepException} and {@see CepNotFoundException} are problems
* with the *request*. Retrying is pointless — the same CEP will fail again.
* - {@see NetworkException}, {@see ServerErrorException} and
* {@see RateLimitedException} are problems with *transport*. Retrying may
* help, and the client already retried on its own before throwing.
*
* That split is why `CepNotFoundException` is not "the HTTP 404 exception":
* `InvalidCepException` is thrown without any request being made at all, when
* the CEP is malformed before it ever leaves the machine.
*/
interface CepisException extends \Throwable
{
}
|