diff --git a/library/Reporting/RetryConnection.php b/library/Reporting/RetryConnection.php index bf13c57..023fcac 100644 --- a/library/Reporting/RetryConnection.php +++ b/library/Reporting/RetryConnection.php @@ -5,15 +5,17 @@ namespace Icinga\Module\Reporting; +use Exception; use ipl\Sql\Connection; +use PDOStatement; class RetryConnection extends Connection { - public function prepexec($stmt, $values = null) + public function prepexec($stmt, $values = null): PDOStatement { try { $sth = parent::prepexec($stmt, $values); - } catch (\Exception $e) { + } catch (Exception $e) { $lostConnection = Str::contains($e->getMessage(), [ 'server has gone away', 'no connection to the server', @@ -45,7 +47,7 @@ public function prepexec($stmt, $values = null) try { $this->connect(); - } catch (\Exception $e) { + } catch (Exception $e) { $noConnection = Str::contains($e->getMessage(), [ 'No such file or directory', 'Connection refused' @@ -55,7 +57,7 @@ public function prepexec($stmt, $values = null) throw $e; } - \sleep(10); + sleep(10); $this->connect(); }