关于[Avoid Using Exceptions to Determine API Status Codes and Responses]的摘要:
It's typical for API endpoints to call application or domain services. In the case of success, the API can simply return Ok and the result of the service call. But for non-success cases, should you use exceptions to communicate from the service to the endpoint, so that it can return an appropriate status code and response? Assuming you read the title of this article, you probably already know the answer I'm going to give. But first let's look at a (bad) example. Consider the following method found in a service that will be called by an API endpoint (controller action)
原文地址: https://ardalis.com/avoid-using-exceptions-determine-api-status/