in reply to Re: Rethrowing with die $@ considered harmful
in thread Rethrowing with die $@ considered harmful
I would consider inadvertently clearing $@ (or $!) as harmful, not the rethrowing.
But there are so many places where this can happen.
eval { foo() } ; if ( $@ ) { bar(); die $@ }
Does bar() throw an exception itself? If it doesn't now will it sometime in the future? What about the stuff that bar() calls? What about the next version of the module Foo used by module Bar used by the bar() function?
If you rely on $@ you're relying on everything in your exception handling code restoring it before you use it. Me - I'll copy it instead. Coupling bad.
Sure the overloading thing is daft - but that doesn't mean copying $@ isn't the right thing to do.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Rethrowing with die $@ considered harmful
by shmem (Chancellor) on Jul 18, 2006 at 08:21 UTC | |
by adrianh (Chancellor) on Aug 01, 2006 at 06:23 UTC | |
|
Re^3: Rethrowing with die $@ considered harmful
by xdg (Monsignor) on Jul 18, 2006 at 11:25 UTC |