473,395 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

on error against try..catch

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
Jan 11 '06 #1
4 1826
Yes, this is included for legacy. Actually the underyling MSIL code for on
error uses Try/Catch...

Try :
http://msdn.microsoft.com/library/de...Statements.asp

You are allowed to do nothing when an exception is raised but I would still
double check that I can't do otherwise (bascially it should IMO never be
done, what is your scenario ?).

--
Patrice

"DavideR" <Da*****@discussions.microsoft.com> a écrit dans le message de
news:4B**********************************@microsof t.com...
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

Jan 11 '06 #2
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

"DavideR" wrote:
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

Jan 11 '06 #3
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
:?)

"Patrice" wrote:
Yes, this is included for legacy. Actually the underyling MSIL code for on
error uses Try/Catch...

Try :
http://msdn.microsoft.com/library/de...Statements.asp

You are allowed to do nothing when an exception is raised but I would still
double check that I can't do otherwise (bascially it should IMO never be
done, what is your scenario ?).

--
Patrice

"DavideR" <Da*****@discussions.microsoft.com> a écrit dans le message de
news:4B**********************************@microsof t.com...
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


Jan 11 '06 #4
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...


--
Patrice

"DavideR" <Da*****@discussions.microsoft.com> a écrit dans le message de
news:4E**********************************@microsof t.com...
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
:?)

"Patrice" wrote:
Yes, this is included for legacy. Actually the underyling MSIL code for on error uses Try/Catch...

Try :
http://msdn.microsoft.com/library/de...Statements.asp
You are allowed to do nothing when an exception is raised but I would still double check that I can't do otherwise (bascially it should IMO never be
done, what is your scenario ?).

--
Patrice

"DavideR" <Da*****@discussions.microsoft.com> a écrit dans le message de
news:4B**********************************@microsof t.com...
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


Jan 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: DraguVaso | last post by:
Hi, I want my application do different actions depending on the exception it gets. For exemple: I have an SQL-table with a unique index. In case I try to Insert a record that's alreaddy in it I...
2
by: matthew.schneider | last post by:
I have a defined XML Schema, and XML documents containing data that I validate against it. Periodically, I will have a data document that will contain extra elements that are not part of my schema....
17
by: ahaupt | last post by:
Hi all, I'm currently writing a load of class libraries, but not the main application iteslf. I want to provide some method for reporting errors back to the main application. At the moment...
4
by: Mike | last post by:
I have a C# aspx page that calls a C# class file for db access, data, etc. If one of the "functions" I call in the class has an error how can i pass that error back to the aspx page and then...
3
by: perlet | last post by:
This is a script I found elsewhere that I was hoping to tweak to do something just a little different. Can't figure out its error. I wouln't mind paying someone to help out if needed to get it to run...
2
by: petschy | last post by:
hello all, i'm writing network message processors for a server app. after dispatching, the processor function is called for the given message type. the tokens in the message are validated,...
13
by: lithoman | last post by:
I'm stumped here. I run the procedure Batch_Select against the database with @ID=18 and I get the expected data. When it loads into a SqlDataReader, it gets messed up somehow. Initially, after the...
9
by: Jim | last post by:
Hello, I'm trying to write exception-handling code that is OK in the presence of unicode error messages. I seem to have gotten all mixed up and I'd appreciate any un-mixing that anyone can...
7
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I wrote a method to validate and xml file against a schema. If the file does not conform to the schema, it throws an error. It works fine except for one curious thing. If I try to validate an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.