From a6b4616d0da909a42b45adde730b0bf831a83aa8 Mon Sep 17 00:00:00 2001 From: Stephen Hoogendijk Date: Thu, 23 Jul 2015 09:40:41 +0200 Subject: [PATCH] Properly fixed exceptions --- src/InfluxDB/Client.php | 2 +- src/InfluxDB/Database.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index faec328cf..2c8b614fa 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -170,7 +170,7 @@ class Client return $driver->query(); } catch (\Exception $e) { - throw new Exception(sprintf('Query has failed, exception: %s', $e->getMessage())); + throw new Exception('Query has failed', $e->getCode(), $e); } } diff --git a/src/InfluxDB/Database.php b/src/InfluxDB/Database.php index e75300261..515fb1cb5 100644 --- a/src/InfluxDB/Database.php +++ b/src/InfluxDB/Database.php @@ -93,7 +93,9 @@ class Database } } catch (\Exception $e) { throw new DatabaseException( - sprintf('Failed to created database %s, exception: %s', $this->name, $e->getMessage()) + sprintf('Failed to created database %s', $this->name), + $e->getCode(), + $e ); } } @@ -138,7 +140,7 @@ class Database return $driver->isSuccess(); } catch (\Exception $e) { - throw new Exception(sprintf('Writing has failed, exception: %s', $e->getMessage())); + throw new Exception('Writing has failed', $e->getCode(), $e); } }