473,503 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error Handling - custom "Throw"?

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
15 2699
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
"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
* "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
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
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
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
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
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
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
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
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
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
Sorry I meant throw exception
example at http://www.vbdotnetheaven.com/Code/Jun2003/2009.asp
Nov 20 '05 #14
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
2987
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
3
1700
by: Dan | last post by:
Hi all! When I throw my custom Exception class the first time in my code, the compiler takes a lot of time for find the following catch EX: try Throw New MyCustomException("test")
13
2037
by: Jacek Dziedzic | last post by:
Hi! <OT, background> I am in a situation where I use two compilers from different vendors to compile my program. It seems that recently, due to a misconfiguration, library conflict or my...
40
3089
by: Mark P | last post by:
I'm implementing an algorithm and the computational flow is a somewhat deep. That is, fcn A makes many calls to fcn B which makes many calls to fcn C, and so on. The return value of the outermost...
12
1899
by: kevineller794 | last post by:
I want to make a split string function, but it's getting complicated. What I want to do is make a function with a String, BeginStr and an EndStr variable, and I want it to return it in a char...
2
1362
by: umangbansal | last post by:
what is the need of throwing exceptions in java??
0
7202
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
7084
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
7278
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
7328
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
7458
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...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.