This question is about coding style.
Say I have a function, f
. f
depends on a condition C
. It calls another function g
as a subroutine. g
also depends on condition C
. If it finds condition C
is not satisfied, it raises an exception. Now, in function f
, should we write:
try:
result = g()
except TheSpecificExcpetionGRaises:
raise
or just plain old
g()
They both pass on the exception, but method one puts the traceback in the scope of function f
, and method two puts the traceback in the scope of function g
.
Note: the condition of C
not being satisfied doesn't imply misuse of the function f
. Or, in CS terms, the condition C is not part of the problem specification, rather we punt when condition C is false.
I don't know why I italicized everything and used math terms.