if not playerIsPlayingForwards():
    raise "Player is not playing forwards'
I'm using this structure instead, liberally raising my own verbose exceptions :
try:
assert playerIsPlayingForwards():
except AssertionError:
    raise PlayerIsNotPlayingInExpectedDirectionError('Forwards')
It takes a bit more time, but it's worth it. You get it back in debug time saved. You also get a nice warm fuzzy feeling when one of your explicit exceptions gets raised, highlighting a very specific problem.
No comments:
Post a Comment