1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-16 11:04:43 +02:00
This commit is contained in:
David Grudl
2011-02-16 19:27:38 +01:00
parent e37af6f99d
commit 1103714b9f
5 changed files with 83 additions and 86 deletions

View File

@@ -8,11 +8,22 @@
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*
* @package dibi
* @package dibi\exceptions
*/
if (!defined('NETTE')) {
class NotImplementedException extends LogicException {}
class NotSupportedException extends LogicException {}
class MemberAccessException extends LogicException {}
class InvalidStateException extends RuntimeException {}
class IOException extends RuntimeException {}
class FileNotFoundException extends IOException {}
}
/**
* dibi common exception.
*
@@ -159,4 +170,28 @@ class DibiDriverException extends DibiException
self::$errorMsg = $message;
}
}
}
/**
* PCRE exception.
*
* @author David Grudl
*/
class DibiPcreException extends Exception {
public function __construct($message = '%msg.')
{
static $messages = array(
PREG_INTERNAL_ERROR => 'Internal error',
PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted',
PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted',
PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data',
5 => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point', // PREG_BAD_UTF8_OFFSET_ERROR
);
$code = preg_last_error();
parent::__construct(str_replace('%msg', isset($messages[$code]) ? $messages[$code] : 'Unknown error', $message), $code);
}
}