473,670 Members | 2,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error detection

cj
I'm working on error handling in my program and need some input.

Dim errorsFound As Boolean = False
Dim respstr As String
Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
errorsFound = True
End Try
If Not errorsFound .....

I'd rather not use boolean errorsFound. What I don't know is if an
exception occured in respstr=proxy.v alidate(soapmes g) can I count on
respstr being empty? If so I'll just say If not respstr = ""
Mar 16 '06 #1
13 2118
cj wrote:
I'm working on error handling in my program and need some input.

Dim errorsFound As Boolean = False
Dim respstr As String
Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
errorsFound = True
End Try
If Not errorsFound .....

I'd rather not use boolean errorsFound. What I don't know is if an
exception occured in respstr=proxy.v alidate(soapmes g) can I count on
respstr being empty? If so I'll just say If not respstr = ""


Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try

Another thought would be to leave the funtion if there is an error.
Mar 16 '06 #2
Chris wrote:
Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try


Or initialize respstr outside of the try block:

respstr = string.empty
Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
End Try

You could then use it (and therefore test if it is empty) outside of the try
block.
Mar 16 '06 #3
cj
Oh Oh, in my haste to make an example I forgot to say Dim respstr As
String = ""

Sorry

The point to the question is is could respstr=proxy.v alidate(soapmes g)
set respstr to something if it generates an exception?

You're indicating it would not. I tend to agree. But Chris said it
might. I don't know how firm each of you are in your beliefs. Let's
see what some others have to say. And by all means feel free to reply
again yourself.
Leon Mayne wrote:
Chris wrote:
Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try


Or initialize respstr outside of the try block:

respstr = string.empty
Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
End Try

You could then use it (and therefore test if it is empty) outside of the try
block.

Mar 16 '06 #4
cj
Good idea. Are you sure it's necessary? Leon seems to think that if
that line throws and exception it would not have changed the value of
respstr. Take a look at my response to his message. Thanks!

Chris wrote:
cj wrote:
I'm working on error handling in my program and need some input.

Dim errorsFound As Boolean = False
Dim respstr As String
Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
errorsFound = True
End Try
If Not errorsFound .....

I'd rather not use boolean errorsFound. What I don't know is if an
exception occured in respstr=proxy.v alidate(soapmes g) can I count on
respstr being empty? If so I'll just say If not respstr = ""


Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try

Another thought would be to leave the funtion if there is an error.

Mar 16 '06 #5
cj wrote:
Oh Oh, in my haste to make an example I forgot to say Dim respstr As
String = ""

Sorry

The point to the question is is could respstr=proxy.v alidate(soapmes g)
set respstr to something if it generates an exception?

You're indicating it would not. I tend to agree. But Chris said it
might. I don't know how firm each of you are in your beliefs. Let's
see what some others have to say. And by all means feel free to reply
again yourself.
Leon Mayne wrote:
Chris wrote:
Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try


Or initialize respstr outside of the try block:

respstr = string.empty
Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
End Try

You could then use it (and therefore test if it is empty) outside of
the try block.

I'm not sure if it will or not, but my theory is, why should I risk it?

Chris
Mar 17 '06 #6
Hi,

If the exception occured when we call the proxy.validate( soapmesg), then
respstr will be untouched.

Also if you do not continue the process in the function, why not just
return in the catch.
If you have finally code, just put it in the Finally block.

You may try to run the code below.

Try
Throw New Exception("Test ")
Catch ex As Exception
MsgBox(ex.ToStr ing())
Return
Finally
MsgBox("Finally called")
End Try

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 17 '06 #7
cj
I can understand your theory but I feel there shouldn't be any guessing
here. There should be an answer. And we should be able to find it.
It's a programming language and we should be able to know what it's
going to do.
I Don't Like Spam wrote:
cj wrote:
Oh Oh, in my haste to make an example I forgot to say Dim respstr As
String = ""

Sorry

The point to the question is is could respstr=proxy.v alidate(soapmes g)
set respstr to something if it generates an exception?

You're indicating it would not. I tend to agree. But Chris said it
might. I don't know how firm each of you are in your beliefs. Let's
see what some others have to say. And by all means feel free to reply
again yourself.
Leon Mayne wrote:
Chris wrote:
Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try

Or initialize respstr outside of the try block:

respstr = string.empty
Try
respstr = proxy.validate( soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
End Try

You could then use it (and therefore test if it is empty) outside of
the try block.

I'm not sure if it will or not, but my theory is, why should I risk it?

Chris

Mar 17 '06 #8
cj
I agree it shouldn't be touched. I feel a lot more confident now that
it will not be.

I feel some folks might have been confused on what I was asking. I see
two types of "errors". I never had a problem with an error being
returned by validate as it'd be returned in respstr and will be checked
for. That type of error wouldn't be an exception caught in ex. This
question was strictly for if the statement throws an exception. Suppose
the connection to the remote machine was lost and validate couldn't be
run. I expect it'd throw an exception and I was confirming respstr in
such a situation would be untouched.

Peter Huang [MSFT] wrote:
Hi,

If the exception occured when we call the proxy.validate( soapmesg), then
respstr will be untouched.

Also if you do not continue the process in the function, why not just
return in the catch.
If you have finally code, just put it in the Finally block.

You may try to run the code below.

Try
Throw New Exception("Test ")
Catch ex As Exception
MsgBox(ex.ToStr ing())
Return
Finally
MsgBox("Finally called")
End Try

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 17 '06 #9
cj
As per your inquiry about why I don't return.

This statement is inside a do loop. If it has an exception I want to
restart the do loop with the next iteration immediately and not run the
rest of the code in the loop--or skip the rest of the code in the loop.
If you'd seen my post on "I miss loop" from 3/14 you'll know that this
was a sticky situation. If I exit do it LEAVES the loop. I no longer
have the command to initiate an immediate jump to the next iteration.

In this section of code if an exception occurs I display it in labels on
the form in case someone is looking but there is little that can be done
about it by the program except try the next loop iteration. So in this
case I really only catch exceptions to keep them from messing up my
execution. The code following the command is looking to see what's in
respstr already. I didn't want to have to set another variable to
indicate an exception occured so respstr can't be trusted. Of coure as
has been suggested, and is a good idea I could ensure respstr is blank
in the catch. But why add an extra line. I know respstr is empty
before the command is run and I SHOULD know if throwing an exception
would put put anything in it.

Peter Huang [MSFT] wrote:
Hi,

If the exception occured when we call the proxy.validate( soapmesg), then
respstr will be untouched.

Also if you do not continue the process in the function, why not just
return in the catch.
If you have finally code, just put it in the Finally block.

You may try to run the code below.

Try
Throw New Exception("Test ")
Catch ex As Exception
MsgBox(ex.ToStr ing())
Return
Finally
MsgBox("Finally called")
End Try

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 17 '06 #10

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

Similar topics

0
3329
by: Cherrish Vaidiyan | last post by:
sir, The following are the steps that i followed in setting up standby database on Red hat Linux 9. i am using Oracle 9i. i have followed the steps in this site : http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96653/create_ps.htm#66206 Still i give the steps i followed. Preparing the Primary Database for Standby Database Creation
2
3009
by: andy johnson | last post by:
I made the mistake of "upgrading" to IE6.0 on my windoze 98 laptop. I really wish bill gates would die in a horribly painful accident. Anyway, after much grief, I downloaded Opera and saw true religion. The good in this is I discovered my web site http://www.oawater.com has a slide show on the main page that is broke in Opera 7.11. I get this error message. Can anyone give me some direction? Event thread: onload Error:
2
2094
by: Simon | last post by:
I have recently set up a server certificate on a web site. Under certain conditions I need to change the color of a html span element. I do this using the following javascript function called from the onreset attribute of the form element. function removeWarningMsg() { if (isIE) { document.all.Warning.style.color = "<%=BACKGROUND_COLOUR%>";
3
11465
by: news.onetel.net.uk | last post by:
I and my friend Karl have spent literally all day trying to find out what is causing my error but we are zapped of any further functionality :) I have a form that adds news records. You select 'City' then you select 'Business Category' - now when you select 'Business Category' the next drop-down menu (business sub category) should populate with 'Business Sub-categories' related to the 'Business Category' but once 'Business Category' is...
7
5881
by: debugger | last post by:
hello, Question, on page load, I populate an existing drop down with createElement and appendChild. It works fine so far. BUT I want to automatically select some option from this populated drop down. So i have this statement: document.getElementById("dropdown").options.selected=true; And it gives me an error.
35
3770
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks gets about 3 or so. It also gets very awkward in nested loops, where you want to check for normal loop processing in the loop condition, not errors. Yes, you could put some generic exit flag in the loop condition, but when you're simply done if...
0
1765
by: JohnQ | last post by:
(The thread "Error Handling Idioms" prompted this post. I meant to post it at the top level, but it got posted as a reply. So here it is again!) An attempt at common defintions: fault: the cause of error. error: a detected fault. error handling: planned processing (perhaps via formal mechanisms) that occurs upon fault detection. error correction: returning a program (or system) back to an error-free
2
1785
by: coolsmaster | last post by:
When I put my code through different inputs, one form of input results in a problem. when I enter: updatename 123456789 10 f9 the expected output is "Error: 10 is out of the range 0-4" whereas I got
3
7319
by: harshadanarvekar | last post by:
Hi Everyone, Here is a part of javascript code that works well in FF2 but shows above error in IE6 and error "missing name after . operator" in NS8 function PopUp(idf,stepX,stepY,speed){
0
1913
by: origami.takarana | last post by:
Intrusion Detection Strategies ----------------------------------- Until now, we’ve primarily discussed monitoring in how it relates to intrusion detection, but there’s more to an overall intrusion detection installation than monitoring alone. Monitoring can help you spot problems in your network, as well as identify performance problems, but watching every second of traffic that passes through your network, manually searching for...
0
8468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8901
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8591
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8660
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4209
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.