From e541cf9ebdb470f14712382f1476a5ee3c000894 Mon Sep 17 00:00:00 2001 From: arisk Date: Fri, 14 Sep 2012 11:16:46 +0700 Subject: [PATCH 1/2] Added PDO error code --- laravel/database/exception.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/laravel/database/exception.php b/laravel/database/exception.php index a116ad70..5ffd3f8e 100644 --- a/laravel/database/exception.php +++ b/laravel/database/exception.php @@ -22,6 +22,7 @@ public function __construct($sql, $bindings, \Exception $inner) $this->inner = $inner; $this->setMessage($sql, $bindings); + $this->setCode(); } /** @@ -37,5 +38,15 @@ protected function setMessage($sql, $bindings) $this->message .= "\n\nSQL: ".$sql."\n\nBindings: ".var_export($bindings, true); } + + /** + * Set the exception code. + * + * @return void + */ + protected function setCode() + { + $this->code = $this->inner->getCode(); + } } \ No newline at end of file From 752161cae3d16a5d0ac9c6a17083f46e1c5eafab Mon Sep 17 00:00:00 2001 From: arisk Date: Fri, 14 Sep 2012 16:47:55 +0700 Subject: [PATCH 2/2] Setting the exception code in the constructor --- laravel/database/exception.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/laravel/database/exception.php b/laravel/database/exception.php index 5ffd3f8e..1d369d98 100644 --- a/laravel/database/exception.php +++ b/laravel/database/exception.php @@ -22,7 +22,9 @@ public function __construct($sql, $bindings, \Exception $inner) $this->inner = $inner; $this->setMessage($sql, $bindings); - $this->setCode(); + + // Set the exception code + $this->code = $inner->getCode(); } /** @@ -39,14 +41,4 @@ protected function setMessage($sql, $bindings) $this->message .= "\n\nSQL: ".$sql."\n\nBindings: ".var_export($bindings, true); } - /** - * Set the exception code. - * - * @return void - */ - protected function setCode() - { - $this->code = $this->inner->getCode(); - } - } \ No newline at end of file