Nette\Database\Drivers\SqliteDriver::convertException PHP Method

convertException() public method

public convertException ( PDOException $e )
$e PDOException
    public function convertException(\PDOException $e)
    {
        $code = isset($e->errorInfo[1]) ? $e->errorInfo[1] : NULL;
        $msg = $e->getMessage();
        if ($code !== 19) {
            return Nette\Database\DriverException::from($e);
        } elseif (strpos($msg, 'must be unique') !== FALSE || strpos($msg, 'is not unique') !== FALSE || strpos($msg, 'UNIQUE constraint failed') !== FALSE) {
            return Nette\Database\UniqueConstraintViolationException::from($e);
        } elseif (strpos($msg, 'may not be NULL') !== FALSE || strpos($msg, 'NOT NULL constraint failed') !== FALSE) {
            return Nette\Database\NotNullConstraintViolationException::from($e);
        } elseif (strpos($msg, 'foreign key constraint failed') !== FALSE || strpos($msg, 'FOREIGN KEY constraint failed') !== FALSE) {
            return Nette\Database\ForeignKeyConstraintViolationException::from($e);
        } else {
            return Nette\Database\ConstraintViolationException::from($e);
        }
    }