I created the following:
public class HttpException
{
public string Text { get; set; }
public string Message { get; set; }
public string InnerExceptionMessage { get; set; }
public string InnerExceptionInnerExceptionMessage { get; set; }
}
I'm calling the class like this:
var e = new HttpException() {
Text = "City not created",
Message = ex.Message,
InnerExceptionMessage = ex.InnerException.Message,
InnerExceptionInnerExceptionMessage = ex.InnerException.InnerException.Message
};
var jsonMsg = JSON.ToJSONString(e);
Is there a way I could make it so I can call the class with just the parameters of a text message and the exception and then have it return a string jsonMsg
Note that the JSON.ToJSONString(e) is an external class that I am using to form a JSON string.
ToString()and useJSON.ToJSONString(e.ToString())?