diff --git a/src/Exceptions/Request/FatalRequestException.php b/src/Exceptions/Request/FatalRequestException.php index 4aef0e5b..bac9179f 100644 --- a/src/Exceptions/Request/FatalRequestException.php +++ b/src/Exceptions/Request/FatalRequestException.php @@ -8,6 +8,15 @@ use Saloon\Http\PendingRequest; use Saloon\Exceptions\SaloonException; +/** + * FatalRequestException + * + * This exception is thrown when the sender encountered a problem before the API + * was able to respond. For example: An issue with connecting to the API or + * an SSL error. + * + * @see https://docs.saloon.dev/the-basics/handling-failures + */ class FatalRequestException extends SaloonException { /** diff --git a/src/Exceptions/Request/RequestException.php b/src/Exceptions/Request/RequestException.php index 66cfa7cf..7be0c710 100644 --- a/src/Exceptions/Request/RequestException.php +++ b/src/Exceptions/Request/RequestException.php @@ -10,6 +10,13 @@ use Saloon\Helpers\StatusCodeHelper; use Saloon\Exceptions\SaloonException; +/** + * RequestException + * + * This exception is thrown when the response from a request is a failed response. + * + * See @https://docs.saloon.dev/the-basics/handling-failures + */ class RequestException extends SaloonException { /** diff --git a/src/Http/PendingRequest.php b/src/Http/PendingRequest.php index deec052d..633f8f36 100644 --- a/src/Http/PendingRequest.php +++ b/src/Http/PendingRequest.php @@ -75,8 +75,6 @@ class PendingRequest /** * Build up the request payload. - * - * @throws \Saloon\Exceptions\DuplicatePipeNameException */ public function __construct(Connector $connector, Request $request, MockClient $mockClient = null) { diff --git a/src/Traits/Connector/SendsRequests.php b/src/Traits/Connector/SendsRequests.php index b1dd7fc6..d578b978 100644 --- a/src/Traits/Connector/SendsRequests.php +++ b/src/Traits/Connector/SendsRequests.php @@ -25,8 +25,6 @@ trait SendsRequests * Send a request synchronously * * @param callable(\Throwable, \Saloon\Http\Request): (bool)|null $handleRetry - * @throws \ReflectionException - * @throws \Throwable */ public function send(Request $request, MockClient $mockClient = null, callable $handleRetry = null): Response { @@ -152,8 +150,6 @@ public function sendAsync(Request $request, MockClient $mockClient = null): Prom * Send a synchronous request and retry if it fails * * @param callable(\Throwable, \Saloon\Http\Request): (bool)|null $handleRetry - * @throws \ReflectionException - * @throws \Throwable */ public function sendAndRetry(Request $request, int $tries, int $interval = 0, callable $handleRetry = null, bool $throw = true, MockClient $mockClient = null): Response { @@ -166,8 +162,6 @@ public function sendAndRetry(Request $request, int $tries, int $interval = 0, ca /** * Create a new PendingRequest - * - * @throws \ReflectionException */ public function createPendingRequest(Request $request, MockClient $mockClient = null): PendingRequest { diff --git a/src/Traits/ManagesExceptions.php b/src/Traits/ManagesExceptions.php index a60030a4..60fb25d8 100644 --- a/src/Traits/ManagesExceptions.php +++ b/src/Traits/ManagesExceptions.php @@ -18,19 +18,19 @@ public function hasRequestFailed(Response $response): ?bool } /** - * Determine if we should throw an exception if the `$response->throw()` ({@see \Saloon\Http\Response::throw()}) - * is used, or when AlwaysThrowOnErrors is used. + * Get the request exception. */ - public function shouldThrowRequestException(Response $response): bool + public function getRequestException(Response $response, ?Throwable $senderException): ?Throwable { - return $response->failed(); + return null; } /** - * Get the request exception. + * Determine if we should throw an exception if the `$response->throw()` is + * used, or when the `AlwaysThrowOnErrors` trait is used. */ - public function getRequestException(Response $response, ?Throwable $senderException): ?Throwable + public function shouldThrowRequestException(Response $response): bool { - return null; + return $response->failed(); } }