From b1bf9938c98cdfd314834a7d6de5369d8620c1d8 Mon Sep 17 00:00:00 2001 From: Ryan Waterston Date: Mon, 6 Jul 2015 10:38:05 -0400 Subject: [PATCH] - Propagated exception messages --- JunosSpace.php | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/JunosSpace.php b/JunosSpace.php index 65d8ced..3d8de1e 100644 --- a/JunosSpace.php +++ b/JunosSpace.php @@ -35,7 +35,6 @@ public function setHTTPHeaders($headers) $this->restlyte->setHTTPHeaders($headers); } - /** * @return mixed */ @@ -98,31 +97,54 @@ public function setUsername($username) public function get($path, $accepts='') { - return $this->request('get', $path, $accepts); + try { + return $this->request('get', $path, $accepts); + } + catch( \Exception $e ) { + throw new \Exception($e->getMessage()); + } } public function post($path, $postData, $accepts='') { - return $this->request('post', $path, $accepts, $postData); + try { + return $this->request('post', $path, $accepts, $postData); + } + catch( \Exception $e ) { + throw new \Exception($e->getMessage()); + } } public function put($path, $postData, $accepts='') { - return $this->request('put', $path, $accepts, $postData); + try { + return $this->request('put', $path, $accepts, $postData); + } + catch( \Exception $e ) { + throw new \Exception($e->getMessage()); + } } public function patch($path, $postData, $accepts='') { - return $this->request('patch', $path, $accepts, $postData); - + try { + return $this->request('patch', $path, $accepts, $postData); + } + catch( \Exception $e ) { + throw new \Exception($e->getMessage()); + } } + public function delete($path, $postData, $accepts='') { - - return $this->request('delete', $path, $accepts, $postData); - + try { + return $this->request('delete', $path, $accepts, $postData); + } + catch( \Exception $e ) { + throw new \Exception($e->getMessage()); + } } public function request($verb, $path, $accepts='', $postData='') @@ -149,10 +171,7 @@ public function request($verb, $path, $accepts='', $postData='') } } catch (\Exception $e) { - - $this->whatIsResponseError($e); - - + throw new \Exception($e->getMessage()); } return $response; @@ -241,4 +260,4 @@ public function whatIsResponseError(\Exception $e) } -} +} \ No newline at end of file