Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Error Handling Misconception

by Anonymous Monk
on Sep 03, 2003 at 22:26 UTC ( #288754=note: print w/replies, xml ) Need Help??


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 23: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 selk (Beadle) on Sep 04, 2003 at 04: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
Re: Re: Re: Error Handling Misconception
by Anonymous Monk on Sep 03, 2003 at 23: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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://288754]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2020-06-05 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (35 votes). Check out past polls.

    Notices?