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); } }