I have a custom exception class as follows:
<Serializable>
Public Class SamException
Inherits Exception
Public Sub New()
' Add other code for custom properties here.
End Sub
Public Property OfferBugSend As Boolean = True
Public Sub New(ByVal message As String)
MyBase.New(message)
' Add other code for custom properties here.
End Sub
Public Sub New(ByVal message As String, ByVal inner As Exception)
MyBase.New(message, inner)
' Add other code for custom properties here.
End Sub
End Class
I'm using this for certain cases in returns from AJAX responses.
In the error function of my AJAX response I am determining that the error is of my custom type like this:
....
ajax code....
.error = function (xhr, text, message) {
var parsed = JSON.parse(xhr.responseText);
var isSamCustomError = (parsed.ExceptionType).toLowerCase().indexOf('samexception') >= 0;
.... etc....
This allows me to post back a specific response to the client if the error is of my custom type.
BUT... I can't seem to get it to post out the extra property OfferBugSend
to the client for the AJAX code to handle this case differently.
console.log("OfferBugSend: " + parsed.OfferBugSend)
is showing undefined, and if I check the response, this is because xhr.responseText
only contains the properties:
ExceptionType
Message
StackTrace
These properties are from the base class Exception
but it is not passing my custom class properties...
How can I make that happen?