Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Error Handling


Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2005, 04:57 PM
SharkBait's Avatar
SharkBait SharkBait is offline
Contributor
 
Join Date: Dec 2004
Location: BC, Canada
Posts: 494
Default Error Handling


Hello,

It seems I am in need of some decent error handling strategies. I've been looking into the Try..Catch..Finally part of it.

Where is the best to use this sort of handling? I'd imagine I wouldnt put it into every function I have would I?

My programs can get the occational runtime error when either the database can not be found or the connection to it has been timedout. Or if some sorta quarky problem has happened.

All I know is I am getting frustrated with runtime errors as it forces the program closed and whatever was being done in it is lost.

Any advice much appreciated

SharkBait
Reply With Quote
  #2  
Old 03-14-2005, 05:08 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

Ideally, you should first be able to know what line(s) raise your error. You should only have a handful of lines that raise an error. If you have an error that occurs in all of your functions, then you should recode and setup a proper initialization sub.
How many lines do you get errors on? You should only need to setup a Try Catch block on the lines that are known or very prone to an error.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 03-15-2005, 07:22 AM
SharkBait's Avatar
SharkBait SharkBait is offline
Contributor
 
Join Date: Dec 2004
Location: BC, Canada
Posts: 494
Default

Quote:
Originally Posted by Iceplug
Ideally, you should first be able to know what line(s) raise your error. You should only have a handful of lines that raise an error. If you have an error that occurs in all of your functions, then you should recode and setup a proper initialization sub.
How many lines do you get errors on? You should only need to setup a Try Catch block on the lines that are known or very prone to an error.
Thats makes sense. So my best bet would be to use try..catch with my MySQL lookups. Since there can be times where the database is unreachable and this would definately cause a runtime error.

So Pseudo wise it would be something like:

Code:
Dim stuff ... Try .... '-- Execute MySQL Connection and Query .... Catch .... '-- Some sorta error handling thingy here ..... End Try

Now I just need to find what type of errors can happen when I do something like this.

Thanx
Reply With Quote
  #4  
Old 03-15-2005, 07:30 AM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

If you caught the type of exception that was thrown (in the error box), you can apply it there. Otherwise, you can catch the generic exception class that catches all catchable exceptions.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->