1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-06 14:16:39 +02:00

added NException

This commit is contained in:
David Grudl
2007-11-14 23:05:57 +00:00
parent 0eeff53fe8
commit 6bfa40f594
13 changed files with 135 additions and 41 deletions

View File

@@ -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();
}
}
}