Embedded Error Handling in Generated Applications

The purpose of this article is to provide you with a useful tool for managing errors.
- Miles Gibson, Consultant and Principal of Milestone Consulting

April 5, 2007
Iron Speed Designer V4.2
Embedded Error Handling in Generated Applications
All of us need feedback to improve, and our applications are no different. If the users of our applications are experiencing issues, we need a reliable and verifiable method of recording and reporting these errors.

I created a simple table called ‘ErrorLog’ in Microsoft SQL Server (easily transferable to Microsoft Access) and then referenced that table in my Iron Speed Designer application.

I then created a simple class called Support.vb to house my error log subroutine. I added the following code to this class:

However, after I created the function and started using it, I realized that I was going to have to declare my support object every time I wanted to use it on a particular page. That, I decided, was too tedious and time consuming. Instead, I discovered that the right place to put common routines is the BaseApplicationPage class. There are also base pages for table and record controls as well. You can access the base pages here, under the Shared folder:

Using Microsoft Visual Studio, I opened the BaseApplicationPage.vb file and added the following code right after the Inherits declaration.

This makes my support object available across all Iron Speed Designer pages! Alas, the problem arose again when I wanted to access my support object from within an App_Code page. However, adding a single line of code into the Table and Record Base Pages solves the problem:

And our table control page...

Now we are ready to use our new support object for error handling. You will have created the table in Microsoft SQL Server or Microsoft Access and referenced this table in Iron Speed Designer. You will have created the Support.vb file (or C# equivalent) and placed it at the root of the App_Code folder.

Example Use:

Note that I am also passing in the current function/subroutine and the logged-in user ID as well.

You can also go another step further and add this into the Iron Speed Designer project templates, so that all new applications have this code automatically included.

You can also copy your support.vb (or equivalent support.cs) file into the following directory:

Placing your file here allows Iron Speed Designer to copy it into your new application folder. You will have to do this for every version of Iron Speed Designer that you install.

Conclusion
The original purpose of this article is to provide you with a useful tool for managing errors.

I hope that you also realize that you can insert your favourite routines into your own Support.vb/Support.cs file. I have given you a nice, clean and easy way to access functionality that is now accessible from every page and class in your application. What could be simpler?

You can download the SQL script and the support class by clicking on this link: Error Handling

About the Author
Miles Gibson
Consultant and Principal of Milestone Consulting

Miles is a senior consultant and principal of Milestone Consulting and has been providing his clients with the right solutions for over twenty three years. He was the first person to offer formal Iron Speed Designer training, and has been coaching and mentoring Iron Speed users for over three years. Miles is an Iron Speed MVP who loves to help clients finish their projects. He is an experienced data modeler who believes in strong database architecture.

Contact the author.



  Privacy Statement