On 1/20/2012 7:40 PM, Steven D'Aprano wrote:
Benjamin Peterson wrote:
2012/1/20 Terry Reedy <tjre...@udel.edu>:
Since 'raise' means 're-raise the current error', 'raise as OtherError'
means (clearly to me, anyway) 're-raise the current error as
OtherError'.

That doesn't make any sense. You're changing the exception completely
not reraising it.

I expect Terry is referring to the coder's intention, not the actual
nuts and bolts of how it is implemented.

Yes, same error situation, translated, typically from developer language to app language.

def spam():
try:
something()
except HamError:
raise SpamError

is implemented by catching a HamError and raising a completely different
SpamError, but the intention is to "replace the HamError which actually
occurred with a more appropriate SpamError".

At least that is *my* intention when I write code like the above, and it
appears to be the usual intention in code I've seen that uses that
idiom. Typically SpamError is part of the function's API while HamError
is not.

--
Terry Jan Reedy

_______________________________________________
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