Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Object-Oriented Thinking

Handling Exceptions

Add Stack Tracing and Logging to Your Projects

Issue: 3.5 (May/June 2005)
Author: Charles Yeomans
Author Bio: Charles Yeomans is a software developer in Lexington, Kentucky.
Article Description: No description available.
Article Length (in bytes): 5,079
Starting Page Number: 33
RBD Number: 3514
Resource File(s): None
Related Link(s): None
Known Limitations: None

Excerpt of article text...

Stack tracing is an oft-requested addition to the REALbasic exception mechanism that hasn't made it yet. Here we will see how to implement it ourselves.

What follows is an exception-handling scheme that I have used to good effect in my own projects. In addition to stack tracing, I also add the ability to log and display information about exceptions. But lest you think that REAL Software has been remiss in not implementing this functionality for us, I point out that the functionality that could not be added by developers is there, and it works.

Try-catch-finally blocks allow one to modularize error-handling and to ensure that cleanup code is always called. Object references are correctly cleaned up and object destructors are always called. Also, exceptions play well with threads. Thus we are left to wish only for features of convenience.

The core of my exception-handling framework is a subclass of RuntimeException, CustomException, that has the features I need. Those features are a Type property, the ability to collect a calling chain, the ability to log and display information, and the ability to convert built-in exceptions to CustomExceptions. Here is the implementation.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com