To throw or to throw not?

Emanuele D'Arrigo manu3d at gmail.com
Thu Nov 13 20:11:26 EST 2008


I'm pondering on what is a bit of a philosophical dilemma.
When should I throw an exception and when should I not?

Suppose I have myFunc1() calling myFunc2() which in turn calls myFunc3
().
Suppose myFunc3() has detected a problem. What should it do?

Throw an exception, forcing myFunc2() to handle it and/or trigger
another exception for myFunc1() to deal with? Or should it simply
return a meaningful error code, for myFunc2() and myFunc1() to handle
as an option but not forcing them to do so?

Manu



More information about the Python-list mailing list