Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
On error
Message
From
02/05/2002 12:30:58
 
 
To
02/05/2002 12:08:38
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00651791
Message ID:
00651964
Views:
16
>i do use try/catch in a few places in my program where i know an error will occur, but how do you use try and catch for the entire program without putting it in every form, every function, and every procedure?

Like I said, catch statements can bubble up. Here's some pseudo code cause I don't have VS.NET handy, but consider this.
try{
//Open the Database
}
catch (SQLException e) {
//this catches a SQL Server problem that expected to catch
//you can view error informatino with e
}
You see here, you're only catching a specific exception, not any exception. Say this was in a method in a class, that was called by your main application somewhere along the line:
try {
//call teh open database class and method
}
catch (Exception e) {
//Now I've caught any exception that occured in managed resources
//and have information about that exception with the e parameter
}
If an error other than your SQL exception occurs when opening the database, this catch statement higher up in the call stack shoudl catch it. And in fact, when you catch teh SQL Exception, you can even throw another exception from that catch loop and it should make it back up to the higher level.

>I probably need to read up more on try/catch/finally

Try Professional VB.NET from Wrox.

>but can it return error information, like what line the error occurred and what tables where open and so forth?

You actually can get a StackTrace off the Exception object.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform