Skip to content

Commit

Permalink
Merge pull request #339 from saloonphp/feature/v3-remove-distrating-@…
Browse files Browse the repository at this point in the history
…throws

Fix | V3 - Remove Distracting @throws from PHPDocs
  • Loading branch information
Sammyjo20 authored Nov 30, 2023
2 parents 4c68cc0 + e6f19fe commit 9a44948
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
9 changes: 9 additions & 0 deletions src/Exceptions/Request/FatalRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Exceptions/Request/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down
2 changes: 0 additions & 2 deletions src/Http/PendingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 0 additions & 6 deletions src/Traits/Connector/SendsRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down
14 changes: 7 additions & 7 deletions src/Traits/ManagesExceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 9a44948

Please sign in to comment.