<?php
	namespace Bolt\Exceptions;

	class Dbo extends \Exception
	{
		protected $codes;

		public function __construct(\PDOException $previous = null)
		{
			$info = $previous->errorInfo;
			$code = $info[1];
			$message = $info[2];

			parent::__construct($message, $code, $previous);
		}
	}
?>

<?php
	namespace Bolt\Exceptions;

	class Dbo extends \Exception
	{
		protected $codes;

		public function __construct(\PDOException $previous = null)
		{
			if ($previous->errorInfo === null)
			{
				preg_match('/SQLSTATE\[(\w+)\] \[(\w+)\] (.*)/', $previous->getMessage(), $matches);
				array_shift($matches);
			}
			else
			{
				$matches = $previous->errorInfo;
			}

			$code = $matches[0];
			$message = sprintf("[%s] %s", $matches[1], $matches[2]);

			parent::__construct($message, hexdec($code), $previous);
		}
	}
?>

Add better parsing of PDO Exceptions for extracting error codes
Add better parsing of PDO Exceptions for extracting error codes
