in reply to Error codes vs die exceptions vs ...
If the failure happens in a subroutine that's deeply nested in many other subroutines, but you need to catch the error somewhere near the top (e.g. to retry the whole operation), it's hard to propagate the error correctly. Throwing an exception (preferably an exception object for easy logging) solves the problem. It doesn't clutter the code, but it should still be used with caution, as the flow is much harder to follow - throwing an exception is just a goto in disguise!
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Error codes vs die exceptions vs ...
by LanX (Saint) on Jul 06, 2019 at 13:49 UTC |
In Section
Seekers of Perl Wisdom