File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -240,16 +240,24 @@ private function render(array $options)
240240 'json ' => $ options ,
241241 ]);
242242 } catch (\GuzzleHttp \Exception \ClientException $ e ) {
243+ $ message = 'No response ' ;
244+
243245 $ response = $ e ->getResponse ();
244- $ body = $ response ? $ response ->getBody () : '' ;
245- $ json = $ response ? json_decode ($ body ) : '' ;
246- $ message = $ body ;
247- if (json_last_error () === JSON_ERROR_NONE ) {
248- $ messages = [];
249- foreach ($ json as $ error ) {
250- $ messages [] = $ error ->message ;
246+
247+ /**
248+ * You could use $e->hasResponse() but that is not accurate enough for phpstan
249+ */
250+ if ($ response !== null ) {
251+ $ message = $ response ->getBody ();
252+
253+ $ json = json_decode ($ message );
254+ if (json_last_error () === JSON_ERROR_NONE ) {
255+ $ messages = [];
256+ foreach ($ json as $ error ) {
257+ $ messages [] = $ error ->message ;
258+ }
259+ $ message = implode (', ' , $ messages );
251260 }
252- $ message = implode (', ' , $ messages );
253261 }
254262
255263 throw new Browserless \APIException ("Failed to render PDF: {$ message }" , $ e ->getCode (), $ e );
You can’t perform that action at this time.
0 commit comments