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.
|










