문제

I have a situation where I want to be able to distinguish between different types of errors within a web service. In an API this would usaully be a separate exception for each, does this mean I should have multiple fault contracts in WCF?

Is this the preferred approach, it seems the OO way to do it. Someone at my work suggested error codes but I'm starting to think it seems counter-intuative if you are sending an exception back.

Has anyone ever been in a similar situation, if so, what design decisions did you undertake and reasons for them?

Thanks, any help would be greatly appreciated. Jamie

도움이 되었습니까?

해결책

Having different fault contracts is the way to go in WCF. Also centralizing the exception handling code in a custom error handler is a good idea. This way you no longer need to write all those try/catch and in the catch clause transform the exception into a fault contract in all service operations.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top