on error against try..catch

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have converted a large vb6 program with an add-in that for every routine
gimme
the error handling:
the add-in adds one line on the head of the routine
"if myerrhandle then ON ERROR GOTO HERRHANDLER"
and the herrhandler label at the botton where i write in a logfile the name
of the routine, the errors and other information
Well setting myerrhandle to true seems that the error handling keeps on
working in
..net is it right? what's the difference from exception handling?
if exception handling is better like i think how can i do to pass from
errhandling to excection handling?
Some times i use on error resume next has got
handling exception an equivalent?
Thasnks
Best Regards
DavideR
 
The "One Error GoTo <label>" part of your VB6 error handling can be converted
automatically to .NET exception handling (download the demo of Clear VB on
our web site to see how).

The stuff that can't be converted easily includes 'On Error Resume Next'
statements. You need to enclose each statement in a try/catch block ("Try"
before the statement, and an empty "Catch" block after the statement). So,
unless your On Error Resume Next is only in effect for a single line or two,
this approach becomes impractical. This code needs to be reworked.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter
 
in some routine like mousemove, graphical drawing etc i sometimes i use
resume next for continue execution of the code for not display a blank screen
(i display an incorrect screen but not blank(this is not my decision but its
so for a long time for customer's impact ! ?!?)
and then i re-establish the herrhandling
So nothing to do?? it's already allright?
Thanks for reply
:?)
 
What kind of errors have you *seen* in this portion of code ?

This is one point where try/cast can help as you can catch only those
exception that are of a given class. This way you can catch errors that
could arise (for example file io errrors when saving a file) but you can
still have more unexpected errors to raise a generic message and warns the
support team.

I wanted to convey the opinion that IMO the worst thing in error hanlding is
to "hide" errors that are not signaleds to the support team and/or the
user...
 
Back
Top