-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PSR-18: Network / Request exception inheritance (#158)
#155 Distinct Network and Request exceptions
- Loading branch information
1 parent
ec4c56a
commit bd87166
Showing
6 changed files
with
84 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace Http\Client\Exception; | ||
|
||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Client\NetworkExceptionInterface as PsrNetworkException; | ||
|
||
/** | ||
|
@@ -11,6 +12,19 @@ | |
* | ||
* @author Márk Sági-Kazár <[email protected]> | ||
*/ | ||
class NetworkException extends RequestException implements PsrNetworkException | ||
class NetworkException extends TransferException implements PsrNetworkException | ||
{ | ||
use RequestAwareTrait; | ||
|
||
/** | ||
* @param string $message | ||
* @param RequestInterface $request | ||
* @param \Exception|null $previous | ||
*/ | ||
public function __construct($message, RequestInterface $request, \Exception $previous = null) | ||
{ | ||
$this->setRequest($request); | ||
|
||
parent::__construct($message, 0, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Http\Client\Exception; | ||
|
||
use Psr\Http\Message\RequestInterface; | ||
|
||
trait RequestAwareTrait | ||
{ | ||
/** | ||
* @var RequestInterface | ||
*/ | ||
private $request; | ||
|
||
private function setRequest(RequestInterface $request) | ||
{ | ||
$this->request = $request; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getRequest(): RequestInterface | ||
{ | ||
return $this->request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters