<!-- Presentation generated by Internet Assistant for Microsoft PowerPoint 97 -->
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft Internet Assistant for Microsoft PowerPoint 97">
<TITLE>More Custom Error Handling</TITLE>
</HEAD>
<BODY >
<CENTER>
<TABLE WIDTH=100%>
<TR> <TD WIDTH=100% ALIGN=CENTER>
<A HREF="sld001.htm">First</A>
<A HREF="sld044.htm">Previous</A>
<A HREF="sld046.htm">Next</A>
<A HREF="sld093.htm">Last</A>
<A HREF="index.htm">Index</A>
<A HREF="dbi.perl.org">Home</A>
<A HREF="tsld045.htm">Text</A>
</TD> </TR>
<TR> <TD WIDTH=100% ALIGN=CENTER>
<IMG SRC="img045.gif" usemap="#Objmap" WIDTH=800 HEIGHT=600 BORDER=0>
</TD> </TR>
</TABLE>
<P>Slide 45 of 93</P>
</CENTER>
<!-- <UL>
<H2>More Custom Error Handling</H2>
</UL></P>
<P><UL>
<LI><H2>It is also possible for HandleError to hide an error, to a limited degree
</H2>
<UL>
<LI>use set_err() to reset $DBI::err and $DBI::errstr
<LI>alter the return value of the failed method
<LI>
</UL>$h->{HandleError} = sub {
<BR> my ($errmsg, $h) = @_;
<BR> return 0 unless $errmsg =~ /^\S+ fetchrow_arrayref failed:/;
<BR> return 0 unless $h->err == 1234; # the error to 'hide'
<BR> $h->set_err(0,""); # turn off the error
<BR> $_[2] = [ ... ]; # supply alternative return value by altering parameter
<BR> return 1;
<BR>};
<LI>
</UL><UL>
<LI><H2>Only works for methods which return a single value and is hard to make reliable (avoiding infinite loops, for example) and so isn't recommended for general use!
</H2>
<UL>
<LI>If you find a good use for it then please let me know.
</UL></UL><UL>
<H2>_</H2>
</UL></P>
<P> -->
</Body>
</HTML>