in reply to Re^2: Best practices for handling exceptions in die/eval style
in thread Best practices for handling exceptions in die/eval style
Clobbering is why, years ago, I changed to the tactic I use now. The $@ can be clobbered in some certain circumstances. The return 1; is the equivalent of just having 1;... the block will return the last expression evaluated (1) without the explicit return().
If you get undef, you know that eval failed (ie. die()d), regardless of/if $@ was populated or not. Localizing $@ is definitely a wise idea if that's the route one wants to take, but it's too much code for me. Keep subs and tests tight and small, and you should be able to know what the problem is specifically, without the need of $@'s contents (that definitely isn't a hard rule by any stretch, so take with a grain of salt).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Best practices for handling exceptions in die/eval style
by krautcat (Acolyte) on Aug 29, 2018 at 22:22 UTC | |
by stevieb (Canon) on Aug 29, 2018 at 22:27 UTC | |
by krautcat (Acolyte) on Sep 05, 2018 at 22:36 UTC | |
|
Re^4: Best practices for handling exceptions in die/eval style
by Anonymous Monk on Sep 06, 2018 at 00:46 UTC |