in reply to Re: Flock, die and statement order
in thread Flock, die and statement order

Unfortunately I can't call any function that will output directly, otherwise I would be using warn or die. If I call warn, I'll end up with something that looks like:

<p>Error Message</p> <html> <head> <title>Error</title> </head> <body> ... </body> </html>

As it stands right now, the script pushes a message onto the error stack, which is checked later in the script. The user is then informed of any errors or sent to the next form if there were no errors. It's not clear from the above snippet that errors are handled but rest assured that they are.

Replies are listed 'Best First'.
Re: Re: Flock, die and statement order
by iburrell (Chaplain) on Nov 19, 2002 at 00:24 UTC
    Why is warn() going to the page? It should be going to STDERR and the server's error log. If you are handling errors, you can catch the die with an eval block.
    eval { might_die() }; if ($@) { # handle exception }

      I guess I misunderstood where warn() outputs to; my apologies. In any case the error message shouldn't be going to the server's error log because it's a message intended for the script's end user.

      I guess I'm just not clear why an eval block / die is better than the nested ifs I have. The script code is well commented and traps errors so what is the advantage of using die?