21.05.13 12:28, Hrvoje Niksic написав(ла):
On 05/21/2013 10:36 AM, Serhiy Storchaka wrote:
     The above exception was converted to the following exception:
     ...

That makes it clear that the conversion was explicit and (hopefully)
intentional, and that the latter exception supersedes the former.

How do you distinguish intentional and unintentional exceptions?

By the use of the "raise" keyword.  Given the code:

try:
     x = d['key']
except KeyError:
     raise BusinessError(...)

....the explicit raising is a giveaway that the new exception was quite
intentional.

try:
    x = d['key']
except KeyError:
    x = fallback('key')

def fallback(key):
    if key not in a:
        raise BusinessError(...)
    return 1 / a[key] # possible TypeError, ZeroDivisionError, etc


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to