Click here to Skip to main content
15,902,189 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: List Boxes Pin
Dave Kreskowiak29-Jun-04 15:47
mveDave Kreskowiak29-Jun-04 15:47 
QuestionWhen is the right time to throw exceptions? Pin
kowplunk29-Jun-04 5:43
kowplunk29-Jun-04 5:43 
AnswerRe: When is the right time to throw exceptions? Pin
kowplunk29-Jun-04 5:46
kowplunk29-Jun-04 5:46 
GeneralRe: When is the right time to throw exceptions? Pin
Blaiser29-Jun-04 6:26
Blaiser29-Jun-04 6:26 
GeneralRe: When is the right time to throw exceptions? Pin
kowplunk29-Jun-04 7:10
kowplunk29-Jun-04 7:10 
GeneralRe: When is the right time to throw exceptions? Pin
Dave Kreskowiak29-Jun-04 8:07
mveDave Kreskowiak29-Jun-04 8:07 
GeneralRe: When is the right time to throw exceptions? Pin
kowplunk29-Jun-04 7:12
kowplunk29-Jun-04 7:12 
GeneralRe: When is the right time to throw exceptions? Pin
Blaiser29-Jun-04 10:02
Blaiser29-Jun-04 10:02 
kowplunk wrote:
Does this mean that you have the whole program running within one big t/c block?

Not really, but it does have that effect. I think of it as a last stop safety net; any errors that occur on the thread which are not otherwised handled get caught here.

Back in VB6, any production app worth its salt would have an error handler in every event routine because if an error occurs here, the app just croaks after VB gives its default error message.

But in .NET you can set an exception handler for the thread, and only write handlers for the errors you can do something about. Like Dave said, if the file a user selects does not exist, or is the wrong format, or they don't have the privs, I'll catch these, provide a specific message, perhaps log the occurance and move on. But if some other kind of error occurs that I don't anticipate, like "Index out of bounds" or "Object is Nothing" (i.e. a defect) then the global handler will catch this, log it, inform the user and give control back to the UI.

Now, as I said, we employ a good number of Try/Finally blocks through-out to be sure we release resources properly (close files, etc.), whether an error occurs or not. But the global handler has worked pretty well for us.

One last point, I would not loose too much sleep over the performance impact of having t/c blocks in your code. IMHO, excepting certain constructs (like tight loops), the impact is generally negligible relative to human response time in using the GUI. $0.02 Wink | ;-)


A person with one watch knows what time it is; a person with two watches is never quite sure ...
[remove "NFS-" from email (No Freaking Spam)]
GeneralRe: When is the right time to throw exceptions? Pin
kowplunk29-Jun-04 10:07
kowplunk29-Jun-04 10:07 
GeneralRe: When is the right time to throw exceptions? Pin
Kevin McFarlane29-Jun-04 11:53
Kevin McFarlane29-Jun-04 11:53 
GeneralOperator variable reference Pin
WESHILL29-Jun-04 5:22
WESHILL29-Jun-04 5:22 
GeneralRe: Operator variable reference Pin
Dave Kreskowiak29-Jun-04 7:56
mveDave Kreskowiak29-Jun-04 7:56 
GeneralRe: Operator variable reference Pin
WESHILL29-Jun-04 8:24
WESHILL29-Jun-04 8:24 
GeneralRe: Operator variable reference Pin
Dave Kreskowiak29-Jun-04 8:34
mveDave Kreskowiak29-Jun-04 8:34 
GeneralRe: Operator variable reference Pin
WESHILL29-Jun-04 8:56
WESHILL29-Jun-04 8:56 
QuestionWinForms component parented as an MDI child in a Win32 app? Pin
Blaiser29-Jun-04 4:33
Blaiser29-Jun-04 4:33 
AnswerRe: WinForms component parented as an MDI child in a Win32 app? Pin
Dave Kreskowiak29-Jun-04 7:58
mveDave Kreskowiak29-Jun-04 7:58 
GeneralCould not set the focus to a text object Pin
dj4198429-Jun-04 4:19
dj4198429-Jun-04 4:19 
GeneralRe: Could not set the focus to a text object Pin
Blaiser29-Jun-04 6:30
Blaiser29-Jun-04 6:30 
GeneralRe: Could not set the focus to a text object Pin
Dave Kreskowiak29-Jun-04 7:42
mveDave Kreskowiak29-Jun-04 7:42 
GeneralEnableVisualStyles Question Pin
beowulfagate28-Jun-04 20:33
beowulfagate28-Jun-04 20:33 
GeneralRe: EnableVisualStyles Question Pin
Dave Kreskowiak29-Jun-04 2:50
mveDave Kreskowiak29-Jun-04 2:50 
Questionhow to convert speech to text Pin
MLSL28-Jun-04 18:25
MLSL28-Jun-04 18:25 
AnswerRe: how to convert speech to text Pin
Dave Kreskowiak29-Jun-04 2:26
mveDave Kreskowiak29-Jun-04 2:26 
GeneralRe: how to convert speech to text Pin
MLSL30-Jun-04 16:48
MLSL30-Jun-04 16:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.