Throw up

Bucky

Well-known member
Joined
Dec 23, 2001
Messages
791
Location
East Coast
User Rank
*Expert*
How do I throw an Exception in a method of a class and have it
travel upwards until it reaches an error handler? In other words,
I want the method to raise an error and the methods caller to
handle the error.

Currently I have the method call surrounded in a Try...Catch block,
but when I Throw the error in the method, the error occurs inside
the method itself.

If this isnt possible, should I just have an Error event and raise
the event when an error occurs?

Thanks
 
Perhaps I dont understand?
Code:
Public MySub()
  Try
      do some processing that could throw an exception
  Catch ex As Exception
     Throw New Exception("Error in MySub",ex)
  End Try

End Sub
Is that what youre asking?
 
Ah, I hadnt thought about that, and that would work great for
the situation that I just described, Im fairly sure.

But just now I realized that the description was incorrect... oops.

The sub that Im throwing the error in is a sub that is called
asinchro-... asyncron-... asyncren-... uh, its called async. :D
Anyway, its a sub thats reading from a socket, so theres no
calling code of the sub to catch the exception.

Ill just set a protected string to the error description, and have
the main method thats called raise the error if the string contains
something.

Thanks Tim :)
 
Your question has given me the neat idea of calling all my exceptions "up" just so I can Throw Up in my code :)
 
Back
Top