locked
Feature Request : Mapping Faults RRS feed

  • General discussion

  • Hi Team,

     

    Marcelo recently outlined in this post (

    http://blogs.msdn.com/marcelolr/archive/2008/06/16/so-special-initializeservice-in-ado-net-data-services.aspx

    ) how the InitializeService Method on ADO.Net Data Services should be implemented.  As I understand it this method is only called per AppDomain and shouldn't contain any logic but configuring access control and whether full verbose exceptions should be thrown. 

     

    My question is around the error handling subject in general.  If we follow best practices we should map our exceptions to HTTP status codes and throw these to the caller.  Firstly I'm not sure where we can inject this on the server side because everything seems to be locked down.  Also, if you don't turn on the UseVerboseErrors nothing is returned to the client, except for the HTTP 500 error that indicates that an internal server error has occurred. 

     

    My question/feature request is how to get around this so that it’s possible to capture the HTTP 500 internal server error and map this to something meaningful to the client.  To explain my point look at Sasha's post on achieving this with WCF Fault conversion (http://www.codeproject.com/KB/WCF/WCFErrorHandling.aspx).  Is this possible to do in Data Services?

     

    I don't think that this will go against REST as long as the HTTP Status Code is thrown.  I just want to be able to deserialize custom exceptions in the client.

     

    Thanks

     

    John

     

     

     

    Wednesday, June 18, 2008 11:24 PM

All replies

  •  

    Hi John,

     This feature already exists .

    you can override HandleException to handle the exception thrown from the data service

     

    Code Snippet

    protected override void HandleException(HandleExceptionArgs args)

    {

    base.HandleException(args);

    }

     

     

    The args include the response code and the exception that's thrown from the service.

    You can wrap this in your custom exception and then deserialize the same on the client.

     

    Thursday, June 19, 2008 12:32 AM
    Moderator
  • Hi Phani,

     

    Yes that works, I guess from here I could call a helper class to map these exceptions.  Is there anyway for custom exceptions to appear in the metadata for the service?

     

    John

    Thursday, June 19, 2008 12:46 AM