Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
We don't bite newbies here... much
 
PerlMonks  

Re: Error Handling Misconception

by bobn (Chaplain)
on Sep 03, 2003 at 18:16 UTC ( [id://288750]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Error Handling Misconception

if the eval fails, it your function probably also returned a false value, which caused your while loop to skip the if ( $@ ) code.

--Bob Niederman, http://bob-n.com

All code given here is UNTESTED unless otherwise stated.

Replies are listed 'Best First'.
Re: Re: Error Handling Misconception
by Anonymous Monk on Sep 03, 2003 at 18:26 UTC

    Thanks for the suggestion. That doesn't seem to be it, though: I still get the program dying w/o error if I do just this:

    my $value = eval { $object->next_value() }; if ($@) { print "BLAH!\n"; } print $value, "\n";

    ...and no output to screen.

      works for me:

      my $object = new wierd; my $value = eval { $object->next_value() }; if ($@) { print "BLAH!\n$@\BLAH!\n"; } print $value, "\n"; package wierd; sub new { bless {}, shift} sub next_value { die "badness"; }
      Produces:
      BLAH! badness at ./tstprog.pl line 13. BLAH!

      Are you sure you're in a situation where you can see what's printed? What happens when the routine works and $value is something printable?

      --Bob Niederman, http://bob-n.com

      All code given here is UNTESTED unless otherwise stated.

      I feel stupid...

      Are you sure you're in a situation where you can see what's printed? What happens when the routine works and $value is something printable?

      Once I took it out of CGI and put it in a text-file to get the minimum error, it worked. There's a bug somewhere in my CGI that I'll have to track down, but this is working fine now. Thank you muchly.

      Make sure a header goes out to the browser before the die message. If your code dies before it had the chance to print the header, then you will likely get an error. I susally just do this at the beginning of my cgi:
      print "Content-type: text/html\n\n";
      Hope that helps,
      selk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://288750]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.