Jay Savage wrote:


die on errors and just keep passing them up the line:

    eval {
        eval {
            eval {
                bad_system_call() or die "$!\n";
            } or die $@;
        } or die $@;
    };

    print "eval says: [EMAIL PROTECTED]" if $@;

As long as you keep propagating $@ in your die calls, the original
error message will get passed out.


I'm getting mixed messages between what you present and the following (I noted the 'or' being a huge difference):

eval {
    eval { success() or die $! };
    if ($@ =~ /a peaceful death/) {
       euthenasia();
       return 0;
    } else {
       die;  # no args!  Will this propogate?
    }
};
if ( $@ =~ /something else/ ) {
  print "something happened that's not fatal\n";
  return 0;
} else {
  die [EMAIL PROTECTED];
}
return 1;

There's a distinct difference (in my own mind at least) between the different errors or responses that an applicatoin/method can have.

There's a fatal error that needs to just kill the application.
There's a really bad error that needs to be mentioned but at least I can respond to the client (net work connection) (return 0)
There's a minor error to report to the client  (return 0).
There's a success process  (return 1).

So I guess the questions that I'm playing with are:
Is my small code block about right?
Will 'die' by itself propogate the contents of $@ ad infinitum?

Is it as hard as I think it is to test exception handling?
I can test some of them, but I can't test the FATAL stuff (unless I code munge).

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to