1

I would like to get automatic exception serialization without manually adding ResponseStatus to the response DTO.

Based on this info on unhandled exception behavior I wrote the following code

public class ContactService : RestServiceBase<Contact>
{
    public override object OnGet(Contact request)
    {
        return ContactApi.GetContactInfo(request);
    }

    //To trigger the serialization of the Exception to ResponseStatus
    protected override object HandleException(Contact request, Exception ex)
    {
        throw ex;
    }

<snip />
}

Do you see any issues with using the library in this manner?

Thanks in advance.

UPDATE: I would like to get the following response when there is an exception without having to add ResponseStatus property to my response DTO object.

I am able to achieve this with by overriding the HandleException method as shown above.

My question is: Can overriding the default exception handling behavior in this manner cause any problems down the road?

{
  "ResponseStatus":{
  "ErrorCode":"ApplicationException",
  "Message":"CRASH",
  }
}
Community
  • 1
  • 1
Alper
  • 663
  • 1
  • 7
  • 24
  • Not entirely clear what you want in the end. What do you want the consumer to see in the end when there is an error? Can you show us an example of the output you want to achieve? – kampsj Aug 23 '12 at 13:03
  • Updated the question to include the output I want to achieve. – Alper Aug 24 '12 at 15:12

0 Answers0