diff options
author | Guillaume Mazoyer <respawneral@gmail.com> | 2014-06-11 09:56:00 +0200 |
---|---|---|
committer | Guillaume Mazoyer <respawneral@gmail.com> | 2014-06-11 09:56:00 +0200 |
commit | c28a69e2eb758b70f8631b2cf5c63d12093a1fc5 (patch) | |
tree | 2b8f9c3376fcc072865da7216eb139589071fa67 /routers | |
parent | 9189da16073a0c2fab560df7fdbe5edb331d8c47 (diff) |
Handle error more properly.
Exception are forwarded up to be able to inform the user about it.
Diffstat (limited to 'routers')
-rw-r--r-- | routers/router.php | 17 |
1 files changed, 11 insertions, 6 deletions
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; } |