How to Exception Handling

Hi,

I wanted to hear your opinion about Exception Handling.
For the predictable error case, I believe that I could handle with IF-Else statement, but what about unpredictable one OR I couldn’t imagine what happens?

Can anyone tell me what is the best practice for handling exception? Try-Catch-Finally?
Do you everyone use that syntax in the every method?

I’m using a lot of Array,Shell objects. Do I have to run close routine in App.close event or Windows.close event?

If you could give me any practical way you’re using, it would really be appreciated.

Thanks.

Why would you not use the Try-Catch-Finally method? It is build for catching unpredictable errors.

[quote=191359:@changwon lee]For the predictable error case, I believe that I could handle with IF-Else statement, but what about unpredictable one OR I couldn’t imagine what happens?

[/quote]

See the App.UnhandledException event.

I thought if I would try to use ‘Try-Catch-Finally’, then I need to put it in the every block of method. I can but it would take so much time. If possible, I should do as much as I can I guess.

With Application.UnhandledException event, I think I can minimize the effort for doing that.

The reason why I made this question is that I just found what you(professional) do about exception handling.

Thanks a lot.

[quote=191388:@changwon lee]I thought if I would try to use ‘Try-Catch-Finally’, then I need to put it in the every block of method. I can but it would take so much time. If possible, I should do as much as I can I guess.

With Application.UnhandledException event, I think I can minimize the effort for doing that.

The reason why I made this question is that I just found what you(professional) do about exception handling.

Thanks a lot.[/quote]

I would advise you develop using Try Catch when you can predict what happens, and with Break On Exception on, so you see potential problems and address them with try Catch. Do not implement UnhandledException code right away, it would mask possible issues. Do it only when your app is finished, as an extra precaution to avoid crashes.

Great. Thanks for the advice!!
I would follow the real best practice.

I had never thought of it that way - that is really good advice - thanks.