将异常返回尝试块的可能性吗?
我有一个愚蠢的QU。仍然任何替代解决方案都会非常有帮助。
我在源中有一个尝试块,该块调用很少的功能。
def main(self):
try:
dict_1 = some_fun_a(self)
dict_2 = some_fun_b(self)
#some operations in dict
except KeyError:
#Raise some exception error.
def some_fun_a(self):
try:
#some validation regarding original data
except ImportError:
#Raise Exception
return ImportError
我可以继承func_a/b&根据REQ更改逻辑。但是,当我在这些功能中面临异常时,主要的尝试块仍然是成功的。
QUS: 无论如何,我是否可以将异常从some_fun_a()返回到main try块中,以便提出了aim()的例外?
I have a stupid qus. Still any alternate solution would be very helpful.
I have a try block in source which calls few functions.
def main(self):
try:
dict_1 = some_fun_a(self)
dict_2 = some_fun_b(self)
#some operations in dict
except KeyError:
#Raise some exception error.
def some_fun_a(self):
try:
#some validation regarding original data
except ImportError:
#Raise Exception
return ImportError
I could inherit func_a/b & change logic as per req. However, when I face exception inside these functions, the main try block is still a success.
QUS:
Is there anyway I could return exception from some_fun_a() to main try block such that exception from main() is raised ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论