views:

56

answers:

2

in my ASP.NET application, I am creating a new class to handle errors in my application and send them to a webservice which will save it in a table.Is there anything wrong in having a Property of type System.Exception class, in my new class ? Currently i have properties like "MethodName","ClassName","InnerException","StackTrace".When an error occurs in my app,I create an object of this class and set the properties and call the save method.Now i am thinking about eliminating the 3 properties and create a property called "Exception" of type Exception.so that i can read the exception details within that class

Is this approach really good ? Would it have any performance /memory issues than the previous method where i have 3 string properties

+2  A: 

There is nothing wrong with storing an Exception object.

SLaks
storing means having a property of that type in my custom class?
Shyju
Yes. Your property would store the `Exception` instance.
SLaks
+1  A: 

Why not send the Exception itself rather than wrapping it in a class? Exception is serializable and you can use extension method to save the Exception information you like in the table on the service side.

e.g.

public static string GetExceptionData(this Exception ex){
    ...
}
Tor