Pass through Exception code in DatabaseException
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 30 Sep 2016 10:43:43 +0000 (12:43 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 30 Sep 2016 10:44:09 +0000 (12:44 +0200)
wcfsetup/install/files/lib/system/database/exception/DatabaseException.class.php
wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php

index 78b10a0fe153bea02866400d9309fd8a3b925b36..36a5ae60067f57f4f49a0bfa95e7a3dc79a2aed6 100644 (file)
@@ -17,5 +17,9 @@ class DatabaseException extends \wcf\system\database\DatabaseException {
         */
        public function __construct($message, \PDOException $previous = null) {
                \Exception::__construct($message, 0, $previous);
+
+               // we cannot use the constructor's parameter, because of (http://php.net/manual/en/exception.getcode.php):
+               // > Returns the exception code as integer in Exception but possibly as other type in Exception descendants (for example as string in PDOException).
+               if ($previous) $this->code = $previous->code;
        }
 }
index 1ca4618411f23a48472a27f43332075616be50dd..92fbf947e82eecc6181c065d23b2758a0963e2b1 100644 (file)
@@ -23,7 +23,7 @@ class DatabaseQueryExecutionException extends DatabaseQueryException implements
         * @inheritDoc
         */
        public function __construct($message, $parameters, \PDOException $previous = null) {
-               \Exception::__construct($message, 0, $previous);
+               parent::__construct($message, $previous);
                
                $this->parameters = $parameters;
        }