我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用exceptions.StandardError()。
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
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)
def __init__(self, msg, code=None): exceptions.StandardError.__init__(self, msg) self.code = code
def __init__(self, msg): self.msg = msg exceptions.StandardError.__init__(self)