File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010namespace Framework \HTTP \Client ;
1111
1212use JetBrains \PhpStorm \ArrayShape ;
13+ use Stringable ;
1314
1415/**
1516 * Class ResponseError.
1617 *
1718 * @package http-client
1819 */
19- class ResponseError
20+ class ResponseError implements Stringable
2021{
2122 protected Request $ request ;
2223 protected string $ error ;
@@ -44,6 +45,11 @@ public function __construct(
4445 $ this ->info = $ info ;
4546 }
4647
48+ public function __toString () : string
49+ {
50+ return 'Error ' . $ this ->getErrorNumber () . ': ' . $ this ->getError ();
51+ }
52+
4753 public function getRequest () : Request
4854 {
4955 return $ this ->request ;
Original file line number Diff line number Diff line change @@ -189,4 +189,18 @@ public function testResponseError() : void
189189 self ::assertSame (6 , $ responses [2 ]->getErrorNumber ());
190190 self ::assertSame ([], $ responses [2 ]->getInfo ());
191191 }
192+
193+ public function testResponseErrorToString () : void
194+ {
195+ $ requests = [
196+ new Request ('https://aplus-framework.tld ' ),
197+ ];
198+ foreach ($ this ->client ->runMulti ($ requests ) as $ response ) {
199+ self ::assertInstanceOf (ResponseError::class, $ response );
200+ self ::assertSame (
201+ 'Error 6: Could not resolve host: aplus-framework.tld ' ,
202+ (string ) $ response
203+ );
204+ }
205+ }
192206}
You can’t perform that action at this time.
0 commit comments