一般来说,对任何特定请求的API返回的所有可能错误进行某种描述会很棒。这将使实现更加可靠,并将改善用户的应用程序反馈。
想象一下,我们需要向用户显示本地化的错误消息,而不仅仅是“请求失败,错误代码为xxx”。
一个很好的例子就是这个错误{"error":"flattr_once","error_description":"You are not allowed to flattr this thing more than once this period","error_uri":"http:\/\/developers.flattr.net\/api"}
。文档中没有提及它,但是应用程序需要理解这一点,并且可能会避免让用户在将来选择flattr这个项目。
答案 0 :(得分:1)
这是我在讨人喜欢时发现的一些回应:
403 {"error":"flattr_once","error_description":"You are not allowed to flattr this thing more than once this period","error_uri":"http:\/\/developers.flattr.net\/api"}
401 {"error":"no_means","error_description":"You don't have any money to flattr with","error_uri":"http:\/\/developers.flattr.net\/api"}
{"error":"flattr_owner","error_description":"You are not allowed to flattr your own thing","error_uri":"http:\/\/developers.flattr.net\/api"}
答案 1 :(得分:0)
开发人员文档中有几个错误说明。例如,flattring failed和standard errors对许多资源具有通用性时的错误响应。