Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Error Handling Misconception

by Anonymous Monk
on Sep 03, 2003 at 18:26 UTC ( [id://288754]=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 Re: Error Handling Misconception
in thread Error Handling Misconception

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.

Replies are listed 'Best First'.
Re: Re: Re: Error Handling Misconception
by bobn (Chaplain) on Sep 03, 2003 at 19:10 UTC

    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.

Re: Re: Re: Error Handling Misconception
by Anonymous Monk on Sep 03, 2003 at 19:54 UTC

    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.

Re: Re: Re: Error Handling Misconception
by selk (Beadle) on Sep 04, 2003 at 00:18 UTC
    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://288754]
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.