Zope
  Home arrow Zope arrow Page 6 - Exception Handling In DTML
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ZOPE

Exception Handling In DTML
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 1
    2002-08-13

    Table of Contents:
  • Exception Handling In DTML
  • Anatomy Class
  • Playing Catch
  • Being Verbose
  • All For One...
  • ...And One For All
  • The Final Solution
  • Raising The Bar
  • Pre-Packaged Python
  • Endzone

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Exception Handling In DTML - ...And One For All


    (Page 6 of 10 )

    Now, the <dtml-try> statement can only deal with exceptions that it knows about. What about the ones the developer can't predict?

    DTML also allows you to specify a catch-all exception handler, one which handles *any* type of exception generated - simply omit the exception name from the <dtml-except> statement. The following code snippet illustrates this technique:

    <dtml-try> <dtml-var alpha> divided by <dtml-var beta> is <dtml-var expr="_.int(alpha)/_.int(beta)" >.<br> <dtml-except> <b>Something bad happened. Call 911.</b> </dtml-try>
    You can even combine this with exception handlers for specific exceptions.

    <dtml-try> <dtml-var alpha> divided by <dtml-var beta> is <dtml-varexpr="_.int(alpha)/_.int(beta)" >.<br><dtml-except KeyError><b>Missing variable.</b><dtml-except ValueError><b>Illegal value.</b><dtml-except><b>Something bad happened. Call 911.</b></dtml-try>
    This way, when an exception occurs, Zope will first check to see if an exception handler has been defined for that exception type. If so, the appropriate handler is invoked; if not, the exception is routed to the catch-all handler, which displays a generic error message.

    More Zope Articles
    More By Harish Kamath, (c) Melonfire


     

       

    ZOPE ARTICLES

    - Creating Zope Products
    - Plone Content Types With Archetypes
    - Flat User Management in Zope
    - Creating Basic Zope Applications
    - Getting started with Zope for Linux and Sola...
    - ZPT Basics (part 4)
    - ZPT Basics (part 3)
    - ZPT Basics (part 2)
    - ZPT Basics (part 1)
    - Exception Handling In DTML
    - DTML Basics (part 4)
    - DTML Basics (part 3)
    - DTML Basics (part 2)
    - DTML Basics (part 1)
    - Using Zope With Apache





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway