Home arrow Zope arrow Page 4 - Exception Handling In DTML

Being Verbose - Zope

Ever wondered if there was a way to stop Zope from barfing error messages all over your screen when one of your scripts crashes and burns? Well, guess what - there is! Meet the and tags, which can be used to trap and resolve errors in script execution.

TABLE OF CONTENTS:
  1. Exception Handling In DTML
  2. Anatomy Class
  3. Playing Catch
  4. Being Verbose
  5. All For One...
  6. ...And One For All
  7. The Final Solution
  8. Raising The Bar
  9. Pre-Packaged Python
  10. Endzone
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 1
August 13, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Now, what you just saw was a very primitive exception handler, albeit one which isn't very useful on a production site. Ideally, you'd want the message generated by the exception handler to be a little more descriptive, and to contain some information on the source of the error.

DTML satisfies this requirement via two special, pre-defined variables - the "error_name" and "error_type" variables. Take a look:

<dtml-try> <dtml-var CheckThisOut> <dtml-except> <b>Something's wrong here! But what?</b><br> This might help:<br> Error type - <i><dtml-var error_type></i> <br> Error value - <i><dtml-var error_value></i> </dtml-try>
Here's the output:


Something's wrong here! But what? This might help:Error type - KeyErrorError value - CheckThisOut
And if you flip back a couple of pages to the very first code snippet in this article, you'll notice a remarkable similarity between the default Zope error output, and that of the script above...not surprising, considering that Zope's default error screen also uses the same two variables.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

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

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: