From 8a68c73fe01932a960430da86bdd25c55b8651b5 Mon Sep 17 00:00:00 2001 From: Tyler Arbon Date: Tue, 3 Jul 2018 17:16:47 -0600 Subject: [PATCH] Do not record PDOException --- src/Components/Recorder.php | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/Components/Recorder.php b/src/Components/Recorder.php index 232f7d9..a540b40 100755 --- a/src/Components/Recorder.php +++ b/src/Components/Recorder.php @@ -24,6 +24,7 @@ class Recorder extends Component { */ protected $absolutelyDontHandle = [ \Tylercd100\LERN\Exceptions\RecorderFailedException::class, + \Doctrine\DBAL\Driver\PDOException::class, ]; /** @@ -56,33 +57,28 @@ public function record(Exception $e) $configDependant = array_keys($this->config['collect']); - try { - foreach ($configDependant as $key) { - if ($this->canCollect($key)) { - $value = $this->collect($key, $e); - if ($value !== null) { - $opts[$key] = $value; - } + foreach ($configDependant as $key) { + if ($this->canCollect($key)) { + $value = $this->collect($key, $e); + if ($value !== null) { + $opts[$key] = $value; } } + } - $class = config('lern.recorder.model'); - $class = !empty($class) ? $class : ExceptionModel::class; + $class = config('lern.recorder.model'); + $class = !empty($class) ? $class : ExceptionModel::class; - $model = new $class(); - foreach($opts as $key => $value) { - $model->{$key} = $value; - } + $model = new $class(); + foreach($opts as $key => $value) { + $model->{$key} = $value; + } - $model->save(); + $model->save(); - Cache::forever($this->getCacheKey($e), Carbon::now()); + Cache::forever($this->getCacheKey($e), Carbon::now()); - return $model; - } catch (Exception $e) { - $code = (is_int($e->getCode()) ? $e->getCode() : 0); - throw new RecorderFailedException($e->getMessage(), $code, $e); - } + return $model; } /**