WCF Error Architecture

I am considering implementing a web services API for our product. I understand how you feel about the general architecture / error handling in WCF. My question is more general of how to develop a common error handling system. For example, I have a method called SaveCompany (companyobject). Each company name must be unique. Let's say you tried to save a second company called "ABC Inc." Do you expect to return an error named "DuplicateCompanyFault", or do you expect to receive an error code or something else? I believe the root of my question is that you prefer to receive errors for processing, an error code, or some combination? These services will be consumed by several different organizations outside of our company on several platforms other than .NET.Any guidance here would be great.

+3
source share
2 answers

From the point of view of the integrator, I would prefer 1 type of error, which represents an error at your API level and within this error encodes the cause of the error and a text description to provide additional information. Otherwise, the error handling logic will be overly complex.

For your example, say that the error code is 100 (which corresponds to the Duplicate Company error in the yall spiffy API documentation), and the description in the message "Failed to add ABC Inc because it already exists."

0
source
0

Source: https://habr.com/ru/post/1756003/


All Articles