Skip to content

Commit 7402292

Browse files
authored
Merge pull request #35 from php-http/deprecate-invalid-exceptions
clients may only throw http exceptions, deprecate configuring other e…
2 parents 407890d + fb600b5 commit 7402292

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Client.php

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ public function doSendRequest(RequestInterface $request)
9292
*/
9393
public function addException(\Exception $exception)
9494
{
95+
if (!$exception instanceof Exception) {
96+
@trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($exception).' will not be possible anymore in the future', E_USER_DEPRECATED);
97+
}
9598
$this->exceptions[] = $exception;
9699
}
97100

@@ -102,6 +105,9 @@ public function addException(\Exception $exception)
102105
*/
103106
public function setDefaultException(\Exception $defaultException = null)
104107
{
108+
if (!$defaultException instanceof Exception) {
109+
@trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED);
110+
}
105111
$this->defaultException = $defaultException;
106112
}
107113

0 commit comments

Comments
 (0)