I was doing this:

eval {
  push @results, "<h1> page content </h1>";
  push @results, "<h2> more page content ...";
  $title = "xyzz";
  if($Data->fetch()) { die "Error, line ".__LINE__; } # I never see this
line number!
}
if($@){
  print $q->header(),  
    start_html(-title => "Error $@"); # This never worked
)else{
  print $q->header(),  
    start_html(-title => "$title");
}
print join("", @results);

This was working except when I got an error: I got no helpful error
messages. Apache HTTP just give me an internal CGI error. When I single
stepped thru the debugger, it seemed to work right in the sense the print
statement would emit the html header. However, the $@ never seemed to have
the string from the die statement.

I'm using HTTPD 2.0.48 and ActiveState Perl 5.8+.

So I changed it:

print $q->header(),  
    start_html(-title => $title);
eval {
  push @results, "<h1> page content </h1>";
  push @results, "<h2> more page content ...";
  $title = "xyzz";
  # this works!
  if($Data->fetch()) { die "Error, line ".__LINE__; }
}
if($@){
  print "<h1>Error $@";  # This now works!
)else{
}
print join("", @results);

This is working much better: I'm getting meaningful error messages from my
die statements with line numbers and even a stack trace when I use the
cgi::trace::trace function in the die statement.

But now the problem is that I am trying to print $title before I have
assigned a value to it. Can someone help me understand how to have a title
that is read from a database and still get meaningful error messages?

If I try to read the $title variable from the database before printing the
$q->header(), I might encounter a die statement and then I'm back to the
problem I started with.

Thanks again,
Siegfried


-- 
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