本文整理汇总了Python中sqlalchemy.util.raise_from_cause方法的典型用法代码示例。如果您正苦于以下问题:Python util.raise_from_cause方法的具体用法?Python util.raise_from_cause怎么用?Python util.raise_from_cause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.util
的用法示例。
在下文中一共展示了util.raise_from_cause方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_raise_from_cause_legacy
# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import raise_from_cause [as 别名]
def test_raise_from_cause_legacy(self):
class MyException(Exception):
pass
class MyOtherException(Exception):
pass
me = MyException("exc on")
def go():
try:
raise me
except Exception:
util.raise_from_cause(MyOtherException("exc two"))
try:
go()
assert False
except MyOtherException as moe:
if testing.requires.python3.enabled:
is_(moe.__cause__, me)
示例2: visit_create_table
# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import raise_from_cause [as 别名]
def visit_create_table(self, create):
table = create.element
preparer = self.preparer
text = "\nCREATE EXTERNAL "
text += "TABLE " + preparer.format_table(table) + " "
text += "("
separator = "\n"
for create_column in create.columns:
column = create_column.element
try:
processed = self.process(create_column)
if processed is not None:
text += separator
separator = ", \n"
text += "\t" + processed
except exc.CompileError as ce:
util.raise_from_cause(
exc.CompileError(
util.u("(in table '{0}', column '{1}'): {2}").format(
table.description, column.name, ce.args[0]
)
)
)
const = self.create_table_constraints(
table,
_include_foreign_key_constraints=create.include_foreign_key_constraints,
)
if const:
text += separator + "\t" + const
text += "\n)\n%s\n\n" % self.post_create_table(table)
return text
示例3: test_raise_from_cause_same_cause
# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import raise_from_cause [as 别名]
def test_raise_from_cause_same_cause(self):
class MyException(Exception):
pass
def go():
try:
raise MyException("exc one")
except Exception as err:
util.raise_from_cause(err)
try:
go()
assert False
except MyException as err:
is_(err.__cause__, None)