Add extra properties in Custom Exception to return to AJAX function : <p>I have a custom exception class as follows:</p>

<pre><code>&lt;Serializable&gt;
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
</code></pre>

<p>I'm using this for certain cases in returns from AJAX responses.</p>

<p>In the error function of my AJAX response I am determining that the error is of my custom type like this:</p>

<pre><code>.... 
ajax code....
.error = function (xhr, text, message) {
    var parsed = JSON.parse(xhr.responseText);
    var isSamCustomError = (parsed.ExceptionType).toLowerCase().indexOf('samexception') &gt;= 0;
 .... etc....
</code></pre>

<p>This allows me to post back a specific response to the client if the error is of my custom type.</p>

<p>BUT... I can't seem to get it to post out the extra property <code>OfferBugSend</code> to the client for the AJAX code to handle this case differently.</p>

<pre><code>console.log("OfferBugSend: " + parsed.OfferBugSend) 
</code></pre>

<p>is showing undefined, and if I check the response, this is because <code>xhr.responseText</code> only contains the properties:</p>

<pre><code>ExceptionType
Message
StackTrace
</code></pre>

<p>These properties are from the base class <code>Exception</code> but it is not passing my custom class properties...</p>

<p>How can I make that happen?</p>
