Here's a good one for ya...
I'm writing some code in a method that intentionally passes bad data to a series of calls in the method.
The problem is, once the first error in the method is encountered, it jumps to the catch and then leaves the routine. What i need it to do is to continue at the next item in the routine that is going to throw an error. Since .NET doesn't seem to have Resume Next, is there any equivalent way to do this
Public Sub CauseErrors
Try
Error1(BadData)
Error2(BadData)
Error3(BadData)
Catch
End Try
End Sub

How can I continue after an error?
Dee_dotnet_79
Hi,
The problem you are facing is not a problem but it is the intended behaviour of Try... Catch block
Structure your Try ... Catch in the following manner to ensure that all the error causing routine are executed.
Public Sub CauseErrors
End Sub
Unless and until you have an alternate flow to rectify the exception in your Catch block i don't see a need to have more than Try... Catch block within a method. If there are code blocks that need to executed independentaly then they form an ideal candidate to isloate it as a seperate methods.
Regards
Arvind T N
big fish713
Let's just let it go... I don't think anybody wants to see that argument pop up again
kicks_joy_darkness
Hi,
You posted something like this before, passing a string to a int property.
A far better way to develop applications is to have the compiler pick up your mistakes without you doing so at runtime. In other words make your program type-safe and don't pass apples when the method is expecting oranges. Trying to test at runtime with non-type safe code will mean that you have to rely on 100% code coverage testing.
It's far easier to let the compiler do it.
LiamD
Thanks, I think I'll use a try for each like you suggested. See, I'm trying to make a program that demonstrates tons of different errors to show people how and where to deal with errors.
For example, I pass an empty string to a function that accepts an Object, a function that accepts a number, a function that accepts a date, etc. and then I pass a number to a function that accepts an Object ... and so on ... to see what kind of errors are caused, and whether they are caused on the caller side or the callee side, so people don't try to handle something in the callee that will never go past the caller.
I just want to purposely demonstrate ton's of different error situations as easily as possible, so it's not really intended to be "sound" programming, which is why your suggestion is going to work brilliantly.
If you've ever done anything like this or have additional idea's on how I might make such a program, please let me know.
Thanks.