Python exceptions 模块,StandardError() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用exceptions.StandardError()

项目:python-phoenixdb    作者:lalinsky    | 项目源码 | 文件源码
def tearDown(self):
        ''' self.drivers should override this method to perform required cleanup
            if any is necessary, such as deleting the test database.
            The default drops the tables that may be created.
        '''
        try:
            con = self._connect()
            try:
                cur = con.cursor()
                for ddl in (self.xddl1,self.xddl2):
                    try:
                        cur.execute(ddl)
                        con.commit()
                    except self.driver.Error:
                        # Assume table didn't exist. Other tests will check if
                        # execute is busted.
                        pass
            finally:
                con.close()
        except _BaseException:
            pass
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def tearDown(self):
        ''' self.drivers should override this method to perform required cleanup
            if any is necessary, such as deleting the test database.
            The default drops the tables that may be created.
        '''
        try:
            con = self._connect()
            try:
                cur = con.cursor()
                for ddl in (self.xddl1,self.xddl2):
                    try:
                        cur.execute(ddl)
                        con.commit()
                    except self.driver.Error:
                        # Assume table didn't exist. Other tests will check if
                        # execute is busted.
                        pass
            finally:
                con.close()
        except _BaseException:
            pass
项目:pymapd    作者:mapd    | 项目源码 | 文件源码
def _translate_exception(e):
    # type: (Exception) -> Exception
    """Translate a thrift-land exception to a DB-API 2.0
    exception.
    """
    # TODO: see if there's a way to get error codes, rather than relying msgs
    if not isinstance(e, TMapDException):
        return e
    if 'Validate failed' in e.error_msg or 'Parse failed' in e.error_msg:
        err = ProgrammingError
    elif 'Exception occurred' in e.error_msg:
        err = DatabaseError
    else:
        err = Error
    return err(e.error_msg)
项目:data007    作者:mobishift2011    | 项目源码 | 文件源码
def __init__(self, msg, code=None):
        exceptions.StandardError.__init__(self, msg)
        self.code = code
项目:PyME    作者:vikramsunkara    | 项目源码 | 文件源码
def __init__(self, msg):
        self.msg = msg
        exceptions.StandardError.__init__(self)