我可以引发异常from
另一个例外,以便提供其他信息,例如:
try:
age = int(x)
except Exception as ex:
raise ValueError("{} is not a valid age.".format(x)) from ex
有没有办法从多个例外来源? e.g。
try:
age = int(x)
except Exception as ex1:
try:
age = date_now().year - parse_date(x).year
except Exception as ex2:
raise ValueError("{} is not a valid age or date.".format(x)) from ex1 + ex2