SunQuest
 
       Zope
  Home arrow Zope arrow Page 3 - 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 
Moblin 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM developerWorks
 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
     
    IBM developerWorks
     
    ADVERTISEMENT

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Exception Handling In DTML - Playing Catch


    (Page 3 of 10 )

    So that's what an error looks like. And now that you've seen what makes it tick, how about writing something to handle it?

    Zope allows you to trap errors using the standard "try-catch" exception-handling combination...or, in the DTML world, <dtml-try> and <dtml-catch>. Here's what it looks like:


    <dtml-try> execute this block <dtml-except err> execute this block if exception "err" is raised </dtml-try>
    Take a look at this rewrite of the previous example, which incorporates a simple exception handler.

    <dtml-try> <dtml-var CheckThisOut><dtml-except><b>Something bad happened</b></dtml-try>
    Now, view this DTML Document and you'll see that the ugly error screen has disappeared; it's been replaced by a simpler (though not very useful) error message.



    The first part of the code introduces you to the <dtml-try> block; this tag instructs Zope to try - literally - to execute the statements within the enclosing block.

    <dtml-try> <dtml-var CheckThisOut>...</dtml-try>
    The <dtml-except> tag sets up the exception handler, in the event that one is generated. This tag does the hard work of trapping the exception and suggesting an alternative path for Zope to proceed with.

    <dtml-except> <b>Something bad happened</b>
    If an exception is generated, the <dtml-except> segment of the code will be triggered, and Zope's default error handling mechanism will be overridden by the instructions in that code segment - in this case, displaying the text "Something bad happened".

    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 6 hosted by Hostway