File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -215,16 +215,15 @@ public function callGraphql($query)
215215 */
216216 public function request ($ method ,$ url ,array $ options )
217217 {
218- try
219- {
218+ try {
220219 $ client = new \GuzzleHttp \Client ();
221220 return $ client ->request ($ method , $ url , $ options );
222221 }
223- catch (RequestException $ e )
224- {
225- $ json_error = json_decode ( $ e -> getResponse ()-> getBody ()-> getContents (), true );
226- if ( isset ( $ json_error[ ' errors ' ])) {
227- $ error_message = \ GuzzleHttp \ json_encode ($ json_error );
222+ catch (RequestException $ e ) {
223+ $ error_response = $ e -> getResponse ()-> getBody ()-> getContents ();
224+ if (! empty ( $ error_response )) {
225+ $ json_error = json_decode ( $ error_response , true );
226+ $ error_message = isset ( $ json_error [ ' errors ' ])? json_encode ( $ json_error [ ' errors ' ]): json_encode ($ json_error );
228227 }
229228 else {
230229 $ error_message = $ e ->getMessage ();
You can’t perform that action at this time.
0 commit comments