From c28a69e2eb758b70f8631b2cf5c63d12093a1fc5 Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Wed, 11 Jun 2014 09:56:00 +0200 Subject: Handle error more properly. Exception are forwarded up to be able to inform the user about it. --- routers/router.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'routers/router.php') diff --git a/routers/router.php b/routers/router.php index b061411..cee1c35 100644 --- a/routers/router.php +++ b/routers/router.php @@ -45,16 +45,21 @@ abstract class Router { try { $complete_command = $this->build_command($command, $parameters); } catch (Exception $e) { - return $e->getMessage(); + throw $e; } $auth = Authentication::instance($this->config); - $auth->connect(); - $data = $auth->send_command($complete_command); - $auth->disconnect(); - log_to_file('[client: '.$this->requester.'] '.$this->config['host'].'> '. - $complete_command); + try { + $auth->connect(); + $data = $auth->send_command($complete_command); + } catch (Exception $e) { + throw $e; + } finally { + $auth->disconnect(); + log_to_file('[client: '.$this->requester.'] '.$this->config['host'].'> '. + $complete_command); + } return $data; } -- cgit v1.2.3