for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Cqrs package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\Cqrs\ReadModel\Storage\Pdo\Exception;
/**
* @author Iqbal Maulana <[email protected]>
* @created 8/20/15
class PdoException extends \PDOException
{
* Constructor.
* @param \PDOException $e
public function __construct(\PDOException $e)
if(strstr($e->getMessage(), 'SQLSTATE[')) {
preg_match('/SQLSTATE\[(\w+)\] \[(\w+)\] (.*)/', $e->getMessage(), $matches);
if (count($matches)) {
$this->code = ($matches[1] == 'HT000' ? $matches[2] : $matches[1]);
$this->message = $matches[3];
} else {
$this->code = $e->getCode();
$this->message = $e->getMessage();
}