We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Error Handling component

martinodea
martinodea asked
on
Medium Priority
209 Views
Last Modified: 2010-04-30
We're just about to launch a large VB SQL Server project.
we would like a comprehensive way of handling errors with 'humane' messages.  Surely this has already been created and there is a component that we can purchase out there.  Granted, there will be a need to alter some of the user messages, depending on what the user is doing...Who has a component based error handler??
Comment
Watch Question

Commented:
When you say component, do you mean OCX, DLL or just a set of classes that you would implement yourself?
Greetings, martinodea,

To complement CoRpSe's comment, I use two kinds of error handling.
1) when I know the code should execute, error or no error:

On Error Resume Next

the Code

If Err then
          Select Case Err
                    Case SomeNumberYouAlreadyKnow
                               strMsg = "MyVeryOwnErrorText"
                     Case Else
                               strMsg = Err.Description
           End Select
           MsgBox strMsg, vbOKOnly, "NameOfCodeAsString: " & Err.Number, _
               Err.HelpFile, Err.HelpContext
End If

2) If I know the code must not be executed on error:

On Error Goto CodeNameAsStringFault:

the Code

CodeNameAsStringFault:
If Err then
          Select Case Err
                    Case SomeNumberYouAlreadyKnow
                               strMsg = "MyVeryOwnErrorText"
                     Case Else
                               strMsg = Err.Description
           End Select
           MsgBox strMsg, vbOKOnly, "NameOfCodeAsString: " & Err.Number, _
               Err.HelpFile, Err.HelpContext
End If

As you can see, the structure of the error handling is the same, only the exact moment the code jumps into error handling is different. Use MsgBox to come up with your own messages.

Imagine!

Commented:
I've found it valuable for everybody to just filter out some errors and keep on running.  For instance, I do a lot of migration systems, and frequently get duplicate key input into a table.  rather than reacting to each of these (I mean it's in there already, how many times you gotta write the thing!), I merely count them and report at the end of the process that nn duplicates were ignored.

Also, since you often get voluminous repetitrive crap in each error message, I have a routine that strips out all the redundant verbiage and shows only the significant discriminating text in the message.  Beyond that, since you often get the same error over and over again in a long process, I save the last error, and report to the user, so and so error followed by the identified cases that fell in that category, just to keep the volume down and not to overly alarm the user.  

Finally, I log the SQL that was involved in the error in a file, so that if an error causing condition can be fixed in a database, the actual file of SQL can be reprocessed, and all recoverablel operations get applied without rerunning the whole process.  Often this is as simple as bringing the file up in the ISQL Query program or in Enterprise Manager and running it as an SQL script.

In VB, you get so many cases of on error cascading hairballs, that you most often have to pick up your reponse logic from studying the actual error patterns your particular configuration of process and garbage in data provoke.

Commented:
I found this error handling method for use in access.  

http://www.wji.com/access/b7174.html

or

If you are looking for an expensive package. Aion, from Platinum Technologies,   has a tool that lets you define your business rules in a "rules database".

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.