mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 14:16:39 +02:00
added NException
This commit is contained in:
@@ -45,9 +45,6 @@ class DibiDatabaseException extends DibiException
|
||||
/** @var string */
|
||||
private $sql;
|
||||
|
||||
/** @var callback */
|
||||
private static $oldHandler;
|
||||
|
||||
|
||||
public function __construct($message = NULL, $code = 0, $sql = NULL)
|
||||
{
|
||||
@@ -70,34 +67,4 @@ class DibiDatabaseException extends DibiException
|
||||
return parent::__toString() . ($this->sql ? "\nSQL: " . $this->sql : '');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function _catchErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
{
|
||||
self::restore();
|
||||
if (ini_get('html_errors')) {
|
||||
$errstr = strip_tags($errstr);
|
||||
}
|
||||
throw new self($errstr, $errno);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function catchError()
|
||||
{
|
||||
self::$oldHandler = set_error_handler(array(__CLASS__, '_catchErrorHandler'), E_ALL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function restore()
|
||||
{
|
||||
if (self::$oldHandler) {
|
||||
set_error_handler(self::$oldHandler);
|
||||
self::$oldHandler = NULL;
|
||||
} else {
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user