![]() |
Practical mod_perl / HTML Version / | ![]() |
||
![]() |
||||
![]() |
![]() |
|||
![]() |
![]() |
|||
![]() |
||||
|
|
||||
![]() |
![]() |
|||
![]() |
E.3.4. Handling Exceptions |
![]() |
||
![]() |
||||
![]() |
![]() |
![]() |
||
![]() |
||||
The exception taglib, AxKit::XSP::Exception, is used to catch exceptions. The syntax is very simple: rather than allowing different types of exceptions, it is currently a very simple try/catch block. To use the exceptions taglib, the following has to be added to httpd.conf:
AxAddXSPTaglib AxKit::XSP::Exception
Then you can implement form validation using exceptions, as Example E-6 demonstrates.
<xsp:page
xmlns:xsp="http://apache.org/xsp/core/v1"
xmlns:param="http://axkit.org/NS/xsp/param/v1"
xmlns:except="http://axkit.org/NS/xsp/exception/v1"
language="Perl"
>
<page>
# form validation:
<except:try>
<xsp:logic>
if ((<param:number/> > 10) || (0 > <param:number/>)) {
die "Number must be between 0 and 10";
}
if (!<param:name/>) {
die "You must supply a name";
}
# Now do something with the params
</xsp:logic>
<p>Values saved successfully!</p>
<except:catch>
<p>Sorry, the values you entered were
incorrect: <except:message/></p>
</except:catch>
</except:try>
</page>
The exact same try/catch (and message) tags can be used for sendmail and for ESQL (discussed in a moment).
 
Continue to:
mod_perl, modperl, Apache, perl, cgi, html, mod_perl, e-commerce, scalability, free, open source, OSS, apache, squid, high availability, modperl, linux, unix, Web, www, mod_perl, webserver, admin, apache, book, webmaster, tools, modperl, guide, docs, documentation, help, mod_perl, perl, information, apache, script, errata, eric cholet, perl, apache, mod-perl, stas bekman, mod_perl, cool, perl, Apache, performance, speed, choice
![]() |
Other projects to check out: meta-religion.com is for those interested in Religious, Spiritual and Esoteric Phenomena. i-want-a-better.com is a community of people discussing what they would like to be improved in their lives and things they use and interact with. You may also want to find a healer in your area or read articles on variety of topics.