By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,224 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,224 IT Pros & Developers. It's quick & easy.

Error Handling - custom "Throw"?

P: n/a
I'd like to create a custom error handler like this in
VB.NET:

....
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).
TIA,

Bill
Nov 20 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Hi Bill,

It certainly is!! Just create a class that derives from "Exception"...

' ===
Public Class LenderNameException
Inherits Exception

Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal Message As String)
MyBase.New(Message)
End Sub

End Class
' ===

and then...

..
..
..
Try
...
Throw New LenderNameException("Hurrah!!")
...
Catch ex As LenderNameException
...
End Try
..
..
..

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"bill salkin" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).
TIA,

Bill

Nov 20 '05 #2

P: n/a
"bill salkin" <an*******@discussions.microsoft.com> schrieb
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).

Write your own class derived from System.Exception.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

P: n/a
* "bill salkin" <an*******@discussions.microsoft.com> scripsit:
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).


\\\
Public Class FooException
Inherits Exception

Public Sub New(...)
Nov 20 '05 #4

P: n/a
Just an FYI...

Non-fatal and application-specific custom exceptions should inherit from
ApplicationException, not Exception.
It's a good convention to follow and allows component consumers to do the
following :

Catch ex As Exception
MsgBox("An unexpected error occurred. Operation cannot be completed")
...
Catch ex1 As ApplicationException
MsgBox(ex1.Message)
End Try

-Rob Teixeira [MVP]

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:uQ*************@TK2MSFTNGP09.phx.gbl...
Hi Bill,

It certainly is!! Just create a class that derives from "Exception"...

' ===
Public Class LenderNameException
Inherits Exception

Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal Message As String)
MyBase.New(Message)
End Sub

End Class
' ===

and then...

.
.
.
Try
...
Throw New LenderNameException("Hurrah!!")
...
Catch ex As LenderNameException
...
End Try
.
.
.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"bill salkin" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).
TIA,

Bill


Nov 20 '05 #5

P: n/a
Thanks to everyone for their replies!

Rob,

Thanks for your reply but I found this gem:

"[Note: ApplicationException does not provide information
as to the cause of the exception. In most scenarios,
instances of this class should not be thrown. In cases
where this class is instantiated, a human-readable message
describing the error should be passed to the constructor.]"

Since I need to know the source of the application error I
may just have to do what the other responders recommended.
(ApplicationException doesn't seem to do the trick.)
Bill


-----Original Message-----
Just an FYI...

Non-fatal and application-specific custom exceptions should inherit fromApplicationException, not Exception.
It's a good convention to follow and allows component consumers to do thefollowing :

Catch ex As Exception
MsgBox("An unexpected error occurred. Operation cannot be completed") ...
Catch ex1 As ApplicationException
MsgBox(ex1.Message)
End Try

-Rob Teixeira [MVP]

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in messagenews:uQ*************@TK2MSFTNGP09.phx.gbl...
Hi Bill,

It certainly is!! Just create a class that derives from "Exception"...
' ===
Public Class LenderNameException
Inherits Exception

Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal Message As String)
MyBase.New(Message)
End Sub

End Class
' ===

and then...

.
.
.
Try
...
Throw New LenderNameException("Hurrah!!")
...
Catch ex As LenderNameException
...
End Try
.
.
.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"bill salkin" <an*******@discussions.microsoft.com> wrote in message news:01****************************@phx.gbl...
> I'd like to create a custom error handler like this in
> VB.NET:
>
> ...
> try
> ...
> Throw ("Lender Name not in table")
> ....
>
> catch ("Lender Name not in table")
> ' handle excpetion, put up nice user message, etc. > catch
> end try
>
> Is something like that possible in VB.NET?
>
> Note that the error is not one of the standard exceptions > that .NET exposes so there is no obvious way to "catch" > it. The error relates to the business logic of the app. (I > don't know if one can "goto" a catch clause -- but I don't > want to code it that way).
>
>
> TIA,
>
> Bill


.

Nov 20 '05 #6

P: n/a
What this is referring to is that ApplicationException by itself tells you
nothing. Rather than throwing an instance of ApplicationException itself,
you are expected to create custom exception classes that inherit from
ApplicationException (read the paragraph above the one you posted). For
example:

<Serializable()> _
Public Class InvalidFinancialSummaryException
Inherits ApplicationException

'REM class code here, including custom Message

End Class

A Catch statement that captures ApplicationException will catch the
InvalidFinancialSummaryException and any other exception that derrives from
ApplicationException. It's a way to organize, categorize, and classify
Exception handling.
By the way, I did make an error in my previous post - the
ApplicationException should be handled BEFORE the generic Exception. It's
important to handle from most specific to most generic.

Here's the quote from the section on creating user-defined exceptions from
the MSDN Exception Handling Fundamentals:
"Do not derive user-defined exceptions from the Exception base class. For
most applications, derive custom exceptions from the ApplicationException
class."

-Rob Teixeira [MVP]

"bill salkin" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Thanks to everyone for their replies!

Rob,

Thanks for your reply but I found this gem:

"[Note: ApplicationException does not provide information
as to the cause of the exception. In most scenarios,
instances of this class should not be thrown. In cases
where this class is instantiated, a human-readable message
describing the error should be passed to the constructor.]"

Since I need to know the source of the application error I
may just have to do what the other responders recommended.
(ApplicationException doesn't seem to do the trick.)
Bill


-----Original Message-----
Just an FYI...

Non-fatal and application-specific custom exceptions should inherit fromApplicationException, not Exception.
It's a good convention to follow and allows component consumers to do thefollowing :

Catch ex As Exception
MsgBox("An unexpected error occurred. Operation cannot be completed") ...
Catch ex1 As ApplicationException
MsgBox(ex1.Message)
End Try

-Rob Teixeira [MVP]

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in messagenews:uQ*************@TK2MSFTNGP09.phx.gbl...
Hi Bill,

It certainly is!! Just create a class that derives from "Exception"...
' ===
Public Class LenderNameException
Inherits Exception

Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal Message As String)
MyBase.New(Message)
End Sub

End Class
' ===

and then...

.
.
.
Try
...
Throw New LenderNameException("Hurrah!!")
...
Catch ex As LenderNameException
...
End Try
.
.
.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"bill salkin" <an*******@discussions.microsoft.com> wrote in message news:01****************************@phx.gbl...
> I'd like to create a custom error handler like this in
> VB.NET:
>
> ...
> try
> ...
> Throw ("Lender Name not in table")
> ....
>
> catch ("Lender Name not in table")
> ' handle excpetion, put up nice user message, etc. > catch
> end try
>
> Is something like that possible in VB.NET?
>
> Note that the error is not one of the standard exceptions > that .NET exposes so there is no obvious way to "catch" > it. The error relates to the business logic of the app. (I > don't know if one can "goto" a catch clause -- but I don't > want to code it that way).
>
>
> TIA,
>
> Bill


.

Nov 20 '05 #7

P: n/a
Try Raise error.
Also you might want to look at www.TechnicalVideos.net they got a
bunch of great stuff on there.

"bill salkin" <an*******@discussions.microsoft.com> wrote in message news:<01****************************@phx.gbl>...
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).
TIA,

Bill

Nov 20 '05 #8

P: n/a
Rob,
You may want to use:
Catch ex As ApplicationException
MsgBox(ex.Message)
Catch ex As Exception
MsgBox("An unexpected error occurred. Operation cannot be completed")
...
End Try
Seeing as Exception is the root class, if you put "Catch ex As Exception"
first, that catch will be the one used, and "Catch ex As
ApplicationException" will never be entered! C# is nice enough to give us a
warning when you reverse the classes... I'll have to remember to try it in
Whidbey...

Also you can reuse the same variable in each catch clause, no need for ex,
ex1, ex2...

Hope this helps
Jay
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl... Just an FYI...

Non-fatal and application-specific custom exceptions should inherit from
ApplicationException, not Exception.
It's a good convention to follow and allows component consumers to do the
following :

Catch ex As Exception
MsgBox("An unexpected error occurred. Operation cannot be completed")
...
Catch ex1 As ApplicationException
MsgBox(ex1.Message)
End Try

-Rob Teixeira [MVP]

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:uQ*************@TK2MSFTNGP09.phx.gbl...
Hi Bill,

It certainly is!! Just create a class that derives from "Exception"...

' ===
Public Class LenderNameException
Inherits Exception

Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal Message As String)
MyBase.New(Message)
End Sub

End Class
' ===

and then...

.
.
.
Try
...
Throw New LenderNameException("Hurrah!!")
...
Catch ex As LenderNameException
...
End Try
.
.
.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"bill salkin" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).
TIA,

Bill



Nov 20 '05 #9

P: n/a
Yep, I caught the ordering error right after posting it, and posted another
response with the correction.
The name of the variable itself doesn't hold much consequence. It's
considered block-level scope, so the compiler will create separate stack
allocations for each regardless of what they are called. Kind of like
re-using I in two different for loops produces local variables v_5 and v_6
(as examples).
All in all, it's a matter of taste, and in my case it probably has something
to with old habits about ambiguous symbols in the reading of the code itself
:-)

-Rob Teixeira [MVP]

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Ol**************@TK2MSFTNGP11.phx.gbl...
Rob,
You may want to use:
Catch ex As ApplicationException
MsgBox(ex.Message)
Catch ex As Exception
MsgBox("An unexpected error occurred. Operation cannot be completed") ...
End Try
Seeing as Exception is the root class, if you put "Catch ex As Exception"
first, that catch will be the one used, and "Catch ex As
ApplicationException" will never be entered! C# is nice enough to give us

a warning when you reverse the classes... I'll have to remember to try it in
Whidbey...

Also you can reuse the same variable in each catch clause, no need for ex,
ex1, ex2...

Hope this helps
Jay
"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
Just an FYI...

Non-fatal and application-specific custom exceptions should inherit from
ApplicationException, not Exception.
It's a good convention to follow and allows component consumers to do the following :

Catch ex As Exception
MsgBox("An unexpected error occurred. Operation cannot be completed") ...
Catch ex1 As ApplicationException
MsgBox(ex1.Message)
End Try

-Rob Teixeira [MVP]

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:uQ*************@TK2MSFTNGP09.phx.gbl...
Hi Bill,

It certainly is!! Just create a class that derives from "Exception"...

' ===
Public Class LenderNameException
Inherits Exception

Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal Message As String)
MyBase.New(Message)
End Sub

End Class
' ===

and then...

.
.
.
Try
...
Throw New LenderNameException("Hurrah!!")
...
Catch ex As LenderNameException
...
End Try
.
.
.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"bill salkin" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
> I'd like to create a custom error handler like this in
> VB.NET:
>
> ...
> try
> ...
> Throw ("Lender Name not in table")
> ....
>
> catch ("Lender Name not in table")
> ' handle excpetion, put up nice user message, etc.
> catch
> end try
>
> Is something like that possible in VB.NET?
>
> Note that the error is not one of the standard exceptions
> that .NET exposes so there is no obvious way to "catch"
> it. The error relates to the business logic of the app. (I
> don't know if one can "goto" a catch clause -- but I don't
> want to code it that way).
>
>
> TIA,
>
> Bill



Nov 20 '05 #10

P: n/a
Hi, Fair enough... Good point, but then...

....
Catch ex As ApplicationException

If TypeOf ex Is MyAppExp1 Then
' Foo
ElseIf TypeOf ex Is MyAppExp2 Then
' Bar
ElseIf TypeOf ex Is MyAppExp3 Then
' Baz
End If

End Try

Yuk. Much simpler, however...

....
Catch ex1 As MyAppExp1
' Foo
Catch ex2 As MyAppExp2
' Bar
Catch ex3 As MyAppExp3
' Baz
End Try
--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
Just an FYI...

Non-fatal and application-specific custom exceptions should inherit from
ApplicationException, not Exception.
It's a good convention to follow and allows component consumers to do the
following :

Catch ex As Exception
MsgBox("An unexpected error occurred. Operation cannot be completed")
...
Catch ex1 As ApplicationException
MsgBox(ex1.Message)
End Try

-Rob Teixeira [MVP]

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:uQ*************@TK2MSFTNGP09.phx.gbl...
Hi Bill,

It certainly is!! Just create a class that derives from "Exception"...

' ===
Public Class LenderNameException
Inherits Exception

Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal Message As String)
MyBase.New(Message)
End Sub

End Class
' ===

and then...

.
.
.
Try
...
Throw New LenderNameException("Hurrah!!")
...
Catch ex As LenderNameException
...
End Try
.
.
.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"bill salkin" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).
TIA,

Bill



Nov 20 '05 #11

P: n/a
Hi Mike,

Raise Error? Doesn't exist in VB.NET...

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"Mike" <Mi*****@Hotmail.com> wrote in message
news:e9**************************@posting.google.c om...
Try Raise error.
Also you might want to look at www.TechnicalVideos.net they got a
bunch of great stuff on there.

"bill salkin" <an*******@discussions.microsoft.com> wrote in message

news:<01****************************@phx.gbl>...
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).
TIA,

Bill

Nov 20 '05 #12

P: n/a
Tom,
"Raise Error" didn't really exist in VB6 either. ;-)

You need to use Err.Raise which is supported in both.

Remember in VB.NET Err is in the Microsoft.VisualBasic.Information Module.

I prefer & recommend using Exceptions over Err.Raise. I only have Err.Raise
in code upgraded from VB6, even then I will Refactor
(http://www.refactoring.com) the code to replace Err.Raise with Exception as
time & code permits...

Hope this helps
Jay

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:OH**************@tk2msftngp13.phx.gbl...
Hi Mike,

Raise Error? Doesn't exist in VB.NET...

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"Mike" <Mi*****@Hotmail.com> wrote in message
news:e9**************************@posting.google.c om...
Try Raise error.
Also you might want to look at www.TechnicalVideos.net they got a
bunch of great stuff on there.

"bill salkin" <an*******@discussions.microsoft.com> wrote in message

news:<01****************************@phx.gbl>...
I'd like to create a custom error handler like this in
VB.NET:

...
try
...
Throw ("Lender Name not in table")
....

catch ("Lender Name not in table")
' handle excpetion, put up nice user message, etc.
catch
end try

Is something like that possible in VB.NET?

Note that the error is not one of the standard exceptions
that .NET exposes so there is no obvious way to "catch"
it. The error relates to the business logic of the app. (I
don't know if one can "goto" a catch clause -- but I don't
want to code it that way).
TIA,

Bill


Nov 20 '05 #13

P: n/a
Sorry I meant throw exception
example at http://www.vbdotnetheaven.com/Code/Jun2003/2009.asp
Nov 20 '05 #14

P: n/a
In reality, it would be more like this (remember, most specific to most
general) -

Catch ex As MyAppExp1
' handle custom exception here
Catch ex As MyAppExp2
' handle other custom exception here
Catch ex As ApplicationException
' handle all other unexpected non-fatal application-specific exceptions
Catch ex As Exception
' handle unexpected base/core exceptions
End Try

Also, don't forget that VB.NET allows user-filtered catch statements (odd
that C# doesn't... yet)

Catch ex As ApplicationException When <Something = Something>
Catch ex As ApplicationException When <Something = SomethingElse>

-Rob Teixeira [MVP]

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi, Fair enough... Good point, but then...

...
Catch ex As ApplicationException

If TypeOf ex Is MyAppExp1 Then
' Foo
ElseIf TypeOf ex Is MyAppExp2 Then
' Bar
ElseIf TypeOf ex Is MyAppExp3 Then
' Baz
End If

End Try

Yuk. Much simpler, however...

...
Catch ex1 As MyAppExp1
' Foo
Catch ex2 As MyAppExp2
' Bar
Catch ex3 As MyAppExp3
' Baz
End Try
--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

Nov 20 '05 #15

P: n/a
Tom,
I didn't say it did..... I'm sorry, obviously someone missed something that someone stated! ;-)

The point of my post was that your statement:
Raise Error? Doesn't exist in VB.NET...

Is false! In VB.NET you use Err.Raise to "Raise Error" just as you do in
VB6.

Hope this helps
Jay

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:Os****************@TK2MSFTNGP10.phx.gbl... I didn't say it did.....

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
Tom,
"Raise Error" didn't really exist in VB6 either. ;-)

You need to use Err.Raise which is supported in both.

Remember in VB.NET Err is in the Microsoft.VisualBasic.Information
Module.
I prefer & recommend using Exceptions over Err.Raise. I only have

Err.Raise
in code upgraded from VB6, even then I will Refactor
(http://www.refactoring.com) the code to replace Err.Raise with

Exception as
time & code permits...

Hope this helps
Jay

"Tom Spink" <thomasdotspinkat@ntlworlddotcom> wrote in message
news:OH**************@tk2msftngp13.phx.gbl...
Hi Mike,

Raise Error? Doesn't exist in VB.NET...

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

"Mike" <Mi*****@Hotmail.com> wrote in message
news:e9**************************@posting.google.c om...
> Try Raise error.
> Also you might want to look at www.TechnicalVideos.net they got a
> bunch of great stuff on there.
>
>
>
> "bill salkin" <an*******@discussions.microsoft.com> wrote in message
news:<01****************************@phx.gbl>...
> > I'd like to create a custom error handler like this in
> > VB.NET:
> >
> > ...
> > try
> > ...
> > Throw ("Lender Name not in table")
> > ....
> >
> > catch ("Lender Name not in table")
> > ' handle excpetion, put up nice user message, etc.
> > catch
> > end try
> >
> > Is something like that possible in VB.NET?
> >
> > Note that the error is not one of the standard exceptions
> > that .NET exposes so there is no obvious way to "catch"
> > it. The error relates to the business logic of the app. (I
> > don't know if one can "goto" a catch clause -- but I don't
> > want to code it that way).
> >
> >
> > TIA,
> >
> > Bill



Nov 20 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.