Exception handling in RIA Service

后端 未结 3 1348
长情又很酷
长情又很酷 2021-02-19 07:20

As you know, it\'s recomended handle exceptions using FaultException with standard WCF service to hide exception details. That\'s fine but i\'m having problem with WCF Ria servi

3条回答
  •  终归单人心
    2021-02-19 07:48

    Here's what Colin Blair answered to my question here

    The DomainService has an overridable method named OnError. Whenever there is an exception within the DomainService itself (not within the WCF code) the exception will be passed to OnError before it is rethrown to be sent back to the client. If you replace the exception in the DomainServiceErrorInfo passed into the OnError method with your own exception then your exception will be the one that gets sent back to the client. If you use the DomainException for your exception then you will be able to pass in an ErrorCode integer which you can use client side to determine the actual error.

    It answers my question and needs. Thanks Colin.

提交回复
热议问题