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

  • Thread starter Thread starter JoeP
  • Start date Start date
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
 
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...
 
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
 
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
 
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
 
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
 
Back
Top