RIA Server Server Exception Handling

I am trying to find a way to handle unhandled exceptions on the server side. I want to control the exception handling at the domain service level so that when I call an operation, I can register the exception and transfer it to some nice words to send it to the client. I found many ways for WCF and classic web services, but nothing for RIA services. Please provide your suggestions.

+4
source share
2 answers

You need to override the DomainService.OnError method, as described in this in the WCF RIA Services I / O block . I did this in the base DomainService class, and not in every single DomainService class in my application, as shown below. The errorInfo.Error property does not have a configuration tool, so I do not think that you can replace the exception object with your own, but the <system.web><customErrors mode="On" /> configuration element can prevent the details that are exposed to the client.

 [EnableClientAccess()] public class DomainServiceBase : DomainService { protected override void OnError(DomainServiceErrorInfo errorInfo) { Logger.WriteException(errorInfo.Error); base.OnError(errorInfo); } } 
+7
source

You can find specific errors and then throw a DomainException that is different from the standard DomainOperationException. There is an ErrorCode in the DomainException that can be used on the client to indicate a condition that will be handled differently on the client.

See Kyle McClellan's answer at http://forums.silverlight.net/forums/t/193028.aspx . Kyle's blog is a very good resource for these types of questions.

+2
source

All Articles