Is that possible to convert an Exception object to SMTPException object?

J

JoeP

Hi All,

Is that possible to convert an Exception object to SMTPException object. I
tried CType() and it did not work!



Thanks,



Joe
 
M

Mark Rae [MVP]

JoeP said:
Hi All,

Is that possible to convert an Exception object to SMTPException object. I
tried CType() and it did not work!


Just throw a new SMTPException...
 
J

JoeP

Hi there,

Here is what I need to do. I have an Err handler routine that logs any error either from an
Exception or an SMTPException.



Within the Catch I call the Handler either for the SMTPException or the Exception. There 2 more properties

in the SMTPException that I need to log while they do no exists in the Exception.



In the err handler methods it starts like this:

Public Sub ErrorHandler(ByVal oErrObject As Object, ByVal cErrorType As String)
End Sub

So this way Either oibject could be picked up and I know which one is which based on the cErrorType,
But I am getting a little message saying as follows: System.InvalidCastException when I hover on top
of the oErrObject. It works fine otherwise.

The way I call the above is:

oInquiery.ErrorHandler(smtpEx, "SMTPErr")
Or
oInquiery.ErrorHandler(generalEx, "GeneralErr")

So any ideas?

Thanks,

Joe
 
J

JoeP

OK the fix for that was:

Public Sub ErrorHandler(ByVal oErrObject As System.Object, ByVal cErrorType As String)
End Sub

Hi there,
Here is what I need to do. I have an Err handler routine that logs any error either from an
Exception or an SMTPException.



Within the Catch I call the Handler either for the SMTPException or the Exception. There 2 more properties

in the SMTPException that I need to log while they do no exists in the Exception.



In the err handler methods it starts like this:

Public Sub ErrorHandler(ByVal oErrObject As Object, ByVal cErrorType As String)
End Sub

So this way Either oibject could be picked up and I know which one is which based on the cErrorType,
But I am getting a little message saying as follows: System.InvalidCastException when I hover on top
of the oErrObject. It works fine otherwise.

The way I call the above is:

oInquiery.ErrorHandler(smtpEx, "SMTPErr")
Or
oInquiery.ErrorHandler(generalEx, "GeneralErr")

So any ideas?

Thanks,

Joe
 
S

sloan

You might want to review this article about good practices:

http://blogs.msdn.com/kcwalina/archive/2005/03/16/396787.aspx



Hi there,

Here is what I need to do. I have an Err handler routine that logs any error either from an
Exception or an SMTPException.



Within the Catch I call the Handler either for the SMTPException or the Exception. There 2 more properties

in the SMTPException that I need to log while they do no exists in the Exception.



In the err handler methods it starts like this:

Public Sub ErrorHandler(ByVal oErrObject As Object, ByVal cErrorType As String)
End Sub

So this way Either oibject could be picked up and I know which one is which based on the cErrorType,
But I am getting a little message saying as follows: System.InvalidCastException when I hover on top
of the oErrObject. It works fine otherwise.

The way I call the above is:

oInquiery.ErrorHandler(smtpEx, "SMTPErr")
Or
oInquiery.ErrorHandler(generalEx, "GeneralErr")

So any ideas?

Thanks,

Joe
 
J

JoeP

Thanks for that tip.

You might want to review this article about good practices:

http://blogs.msdn.com/kcwalina/archive/2005/03/16/396787.aspx



Hi there,

Here is what I need to do. I have an Err handler routine that logs any error either from an
Exception or an SMTPException.



Within the Catch I call the Handler either for the SMTPException or the Exception. There 2 more properties

in the SMTPException that I need to log while they do no exists in the Exception.



In the err handler methods it starts like this:

Public Sub ErrorHandler(ByVal oErrObject As Object, ByVal cErrorType As String)
End Sub

So this way Either oibject could be picked up and I know which one is which based on the cErrorType,
But I am getting a little message saying as follows: System.InvalidCastException when I hover on top
of the oErrObject. It works fine otherwise.

The way I call the above is:

oInquiery.ErrorHandler(smtpEx, "SMTPErr")
Or
oInquiery.ErrorHandler(generalEx, "GeneralErr")

So any ideas?

Thanks,

Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top