添加DB异常和Error异常

This commit is contained in:
麦当苗儿
2016-01-29 12:49:23 +08:00
parent 968adbeca4
commit a29f51ced2
2 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://zjzit.cn>
// +----------------------------------------------------------------------
namespace think\exception;
use think\Exception;
/**
* Database相关异常处理类
*/
class DbException extends Exception
{
public function __construct($message, $code, $db, $config)
{
$this->message = $message;
$this->code = $code;
$error = explode(':', $db->getError());
$this->setData('Database Status', [
'Error Code' => $error[0],
'Error Message' => $error[1],
'Error SQL' => $db->getLastSql()
]);
$this->setData('Database Config', $config);
}
}