From 35fa16867a6358bd7d0cdb9fb32cad86a39531b7 Mon Sep 17 00:00:00 2001 From: Justas Butkus Date: Fri, 30 Jan 2015 07:59:15 +0100 Subject: [PATCH 1/2] Just one type of exception provides response object. Fix issue where an untyped exception was requested to hold response object. If error happens earlier (i.e. cURL error) this is not true and process fail to cleanly abort. --- php/class-terminus-command.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/php/class-terminus-command.php b/php/class-terminus-command.php index 4c6dad64d..ba377a8ea 100755 --- a/php/class-terminus-command.php +++ b/php/class-terminus-command.php @@ -153,9 +153,14 @@ public static function request($realm, $uuid, $path = FALSE, $method = 'GET', $o ); $cache->put_data($cachekey, $data); return $data; - } catch( Exception $e ) { + } catch( Guzzle\Http\Exception\BadResponseException $e ) { $response = $e->getResponse(); \Terminus::error("%s", $response->getBody(TRUE) ); + } catch( Guzzle\Http\Exception\BadResponseException $e ) { + $request = $e->getRequest(); + \Terminus::error("Request %s had failed: %s", (string)$request, $e->getMessage() ); + } catch( Exception $e ) { + \Terminus::error("Unrecognised request failure: %s", $e->getMessage() ); } } From 4106f748846f9b037ad4ae1a731e4767d0a22199 Mon Sep 17 00:00:00 2001 From: Justas Butkus Date: Sun, 8 Feb 2015 17:32:35 +0100 Subject: [PATCH 2/2] Typo: same exception was used in two catch lines. Changed to use HttpException interface. --- php/class-terminus-command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/class-terminus-command.php b/php/class-terminus-command.php index ba377a8ea..842fb5979 100755 --- a/php/class-terminus-command.php +++ b/php/class-terminus-command.php @@ -156,7 +156,7 @@ public static function request($realm, $uuid, $path = FALSE, $method = 'GET', $o } catch( Guzzle\Http\Exception\BadResponseException $e ) { $response = $e->getResponse(); \Terminus::error("%s", $response->getBody(TRUE) ); - } catch( Guzzle\Http\Exception\BadResponseException $e ) { + } catch( Guzzle\Http\Exception\HttpException $e ) { $request = $e->getRequest(); \Terminus::error("Request %s had failed: %s", (string)$request, $e->getMessage() ); } catch( Exception $e ) {