Skip to content

Commit 9f434a4

Browse files
committed
Play with exceptions
1 parent 2a26ef0 commit 9f434a4

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

src/Exception/HttpClientException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* @author GeLo <[email protected]>
1111
*/
12-
class HttpClientException extends \Exception implements Exception
12+
class HttpClientException extends \RuntimeException implements Exception
1313
{
1414
/**
1515
* @var RequestInterface|null
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Http\Client\Exception;
4+
5+
use Http\Client\Exception;
6+
7+
/**
8+
* Custom Invalid Argument exception
9+
*
10+
* @author Márk Sági-Kazár <[email protected]>
11+
*/
12+
class InvalidArgumentException extends \InvalidArgumentException implements Exception
13+
{
14+
15+
}

src/Exception/MultiHttpClientException.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
/**
99
* @author GeLo <[email protected]>
1010
*/
11-
class MultiHttpClientException extends \Exception implements Exception
11+
class MultiHttpClientException extends \RuntimeException implements Exception
1212
{
1313
/**
14-
* @var HttpAdapterException[]
14+
* @var HttpClientException[]
1515
*/
1616
private $exceptions;
1717

@@ -21,8 +21,8 @@ class MultiHttpClientException extends \Exception implements Exception
2121
private $responses;
2222

2323
/**
24-
* @param HttpAdapterException[] $exceptions
25-
* @param ResponseInterface[] $responses
24+
* @param HttpClientException[] $exceptions
25+
* @param ResponseInterface[] $responses
2626
*/
2727
public function __construct(array $exceptions = [], array $responses = [])
2828
{
@@ -35,7 +35,7 @@ public function __construct(array $exceptions = [], array $responses = [])
3535
/**
3636
* Returns all exceptions
3737
*
38-
* @return HttpAdapterException[]
38+
* @return HttpClientException[]
3939
*/
4040
public function getExceptions()
4141
{
@@ -45,11 +45,11 @@ public function getExceptions()
4545
/**
4646
* Checks if a specific exception exists
4747
*
48-
* @param HttpAdapterException $exception
48+
* @param HttpClientException $exception
4949
*
5050
* @return boolean TRUE if there is the exception else FALSE.
5151
*/
52-
public function hasException(HttpAdapterException $exception)
52+
public function hasException(HttpClientException $exception)
5353
{
5454
return array_search($exception, $this->exceptions, true) !== false;
5555
}
@@ -67,7 +67,7 @@ public function hasExceptions()
6767
/**
6868
* Sets the exceptions
6969
*
70-
* @param HttpAdapterException[] $exceptions
70+
* @param HttpClientException[] $exceptions
7171
*/
7272
public function setExceptions(array $exceptions)
7373
{
@@ -78,17 +78,17 @@ public function setExceptions(array $exceptions)
7878
/**
7979
* Adds an exception
8080
*
81-
* @param HttpAdapterException $exception
81+
* @param HttpClientException $exception
8282
*/
83-
public function addException(HttpAdapterException $exception)
83+
public function addException(HttpClientException $exception)
8484
{
8585
$this->exceptions[] = $exception;
8686
}
8787

8888
/**
8989
* Adds some exceptions
9090
*
91-
* @param HttpAdapterException[] $exceptions
91+
* @param HttpClientException[] $exceptions
9292
*/
9393
public function addExceptions(array $exceptions)
9494
{
@@ -100,9 +100,9 @@ public function addExceptions(array $exceptions)
100100
/**
101101
* Removes an exception
102102
*
103-
* @param HttpAdapterException $exception
103+
* @param HttpClientException $exception
104104
*/
105-
public function removeException(HttpAdapterException $exception)
105+
public function removeException(HttpClientException $exception)
106106
{
107107
unset($this->exceptions[array_search($exception, $this->exceptions, true)]);
108108
$this->exceptions = array_values($this->exceptions);
@@ -111,7 +111,7 @@ public function removeException(HttpAdapterException $exception)
111111
/**
112112
* Removes some exceptions
113113
*
114-
* @param HttpAdapterException[] $exceptions
114+
* @param HttpClientException[] $exceptions
115115
*/
116116
public function removeExceptions(array $exceptions)
117117
{

0 commit comments

Comments
 (0)