From 55fe21ef110cdb3c988c3174ed6172b8f8228c26 Mon Sep 17 00:00:00 2001 From: Mikeias Silva Date: Thu, 28 Aug 2025 10:06:24 -0300 Subject: [PATCH 1/2] =?UTF-8?q?fix/feature:=20problema=20de=20silent=20exc?= =?UTF-8?q?eptions,=20agora=20todo=20erro=20gerar=C3=A1=20uma=20exception?= =?UTF-8?q?=20na=20aplica=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Database/Connection.php | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/Database/Connection.php b/src/Database/Connection.php index c100a4c..9a1e32f 100644 --- a/src/Database/Connection.php +++ b/src/Database/Connection.php @@ -475,4 +475,43 @@ public function getSchemaBuilder() return $builder; } + + /** + * Run a SQL statement. + * + * @param string $query + * @param array $bindings + * @param \Closure $callback + * @return mixed + * + * @throws \Illuminate\Database\QueryException + */ + protected function runQueryCallback($query, $bindings, Closure $callback) + { + try { + $result = $callback($query, $bindings); + + if ($result instanceof \PDOStatement) { + if (isset($errorInfo[0]) && $errorInfo[0] !== '00000') { + $errorInfo = $result->errorInfo(); + $finalErrorMessage = sprintf( + 'SQLSTATE[%s] [%d] %s', + $errorInfo[0], + (int)$errorInfo[1], + trim(preg_replace(['/^\[\d+\]\s\(severity\s\d+\)\s/', '/\s+/'], ['', ' '], $errorInfo[2])) + ); + throw new \PDOException($finalErrorMessage, (int)$errorInfo[1]); + } + } + return $result; + + } catch (Throwable $e) { + throw new QueryException( + $this->getName(), + $query, + $this->prepareBindings($bindings), + $e + ); + } + } } From 9007e6924a3e1ae3b40608e14ff1a848f825d549 Mon Sep 17 00:00:00 2001 From: Mikeias Silva Date: Thu, 28 Aug 2025 10:51:35 -0300 Subject: [PATCH 2/2] fix variavel errorinfo --- src/Database/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Connection.php b/src/Database/Connection.php index 9a1e32f..543bda7 100644 --- a/src/Database/Connection.php +++ b/src/Database/Connection.php @@ -492,8 +492,8 @@ protected function runQueryCallback($query, $bindings, Closure $callback) $result = $callback($query, $bindings); if ($result instanceof \PDOStatement) { + $errorInfo = $result->errorInfo(); if (isset($errorInfo[0]) && $errorInfo[0] !== '00000') { - $errorInfo = $result->errorInfo(); $finalErrorMessage = sprintf( 'SQLSTATE[%s] [%d] %s', $errorInfo[0],