in reply to Managing errors in subroutines
# starting point sub start { eval { call1(); call2(); }; return 0 if $@; return 1; } sub call1 { # code here die "Error in call1" if $something_nasty; call3(); # more code } sub call2 { # code here die "Error in call2" if $something_nasty; # more code here.. } sub call3 { # code here die "Error in call3" if $something_nasty; # more code here.. }
In other words use die and eval BLOCK to trow and catch exceptions, and you won't have to check every subroutine call, just catch the error at the place you want to process it.
See the die and eval entries in perlfunc for more info.
-- Joost downtime n. The period during which a system is error-free and immune from user input.
|
|---|