How do I throw an exception when my database API reports an error code? The
database implementation does not throw exceptions so I have to.
Thanks again!
Siegfried

-----Original Message-----
From: Peter Scott [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 29, 2004 4:19 AM
To: beginners@perl.org
Subject: Re: How to throw exceptions for perl cgi program?

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Siegfried Heintze) writes:
>I'm buffering my html/javascript output in a large array of strings. This
>frees me to perform my computations independently of the order they appear
>in the output.
>
>However, I have a problem: Let us suppose I have an error from my database
>and I have not executed "print $q->header( ),start_html(-title =>
>$case_name);"; yet.
>
>Is there a way I can throw an exception in my function (that retrieves data
>from the database) and let the main program have an exception handler that
>will execute "print $q->header( ),start_html(-title => $case_name);"
earlier
>than normal so I can print my error messages and abort?

Main program:

eval {
  # Save output in $page
};
if ($@) {
  print $q->header, start_html(-title => 'Error'),
        p("Error: $@");
}
else {
  print $q->header, start_html(-title => $case_name);
  print $page;
}
 
-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




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