Message124735
I like MRAB's suggestion best:
MRAB wrote:
> Suggestion: an explicit 'raise' in the exception handler excludes the
> context, but if you want to include it then 'raise with'. For example:
>
> # Exclude the context
> try:
> command_dict[command]()
> except KeyError:
> raise CommandError("Unknown command")
>
> # Include the context
> try:
> command_dict[command]()
> except KeyError:
> raise with CommandError("Unknown command")
I think we can even strike off the verbiage "in the exception handler"... that way, raise always does the same thing -- raise KeyError will raise a KeyError, always, not sometimes a KeyError and sometimes a KeyError nested in a WhatEverError. |
|
Date |
User |
Action |
Args |
2010-12-27 21:37:38 | ethan.furman | set | recipients:
+ ethan.furman, ncoghlan, pitrou, draghuram, steven.daprano, poke |
2010-12-27 21:37:37 | ethan.furman | set | messageid: <1293485857.86.0.678566183543.issue6210@psf.upfronthosting.co.za> |
2010-12-27 21:37:34 | ethan.furman | link | issue6210 messages |
2010-12-27 21:37:33 | ethan.furman | create | |
|