This repository was archived by the owner on Dec 6, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public function post($url, SimpleXMLElement $body)
4242
4343 return new SimpleXMLElement ($ response ->getBody ());
4444 } catch (RequestException $ e ) {
45- throw new PagSeguroException ($ e ->getMessage (), $ e -> getCode (), $ e );
45+ throw PagSeguroException:: create ($ e ->getResponse () );
4646 }
4747 }
4848
@@ -55,9 +55,10 @@ public function get($url)
5555 {
5656 try {
5757 $ response = $ this ->client ->request ('GET ' , $ url , ['verify ' => false ]);
58+
5859 return new SimpleXMLElement ($ response ->getBody ());
5960 } catch (RequestException $ e ) {
60- throw new PagSeguroException ($ e ->getMessage ());
61+ throw PagSeguroException:: create ($ e ->getResponse ());
6162 }
6263 }
6364}
Original file line number Diff line number Diff line change @@ -7,12 +7,13 @@ class PagSeguroException extends \RuntimeException
77{
88 /**
99 * @param ResponseInterface $response
10+ * @param \Exception|null $cause
1011 *
1112 * @return PagSeguroException
1213 */
13- public static function create (ResponseInterface $ response )
14+ public static function create (ResponseInterface $ response, \ Exception $ cause = null )
1415 {
15- return new static (static ::createMessage ($ response ));
16+ return new static (static ::createMessage ($ response ), null , $ cause );
1617 }
1718
1819 /**
@@ -22,8 +23,8 @@ public static function create(ResponseInterface $response)
2223 */
2324 protected static function createMessage (ResponseInterface $ response )
2425 {
25- if ($ response ->getStatusCode () != 400 ) {
26- return '[ ' . $ response ->getStatusCode () . '] A HTTP error has occurred: ' . $ response ->getBody (true );
26+ if ($ response ->getStatusCode () !== 400 ) {
27+ return '[ ' . $ response ->getStatusCode () . '] A HTTP error has occurred: ' . $ response ->getBody ();
2728 }
2829
2930 $ message = 'Some errors occurred: ' ;
You can’t perform that action at this time.
0 commit comments