💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
JSON对象的_error_属性应包含以下属性。 ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorcode)error.code ~~~ 属性值类型: 整数(integer) 父节点: error ~~~ 表示该错误的编号。这个属性通常表示HTTP响应码。如果存在多个错误,_code_应为第一个出错的错误码。 示例: ~~~ { "error":{ "code": 404 } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errormessage)error.message ~~~ 属性值类型: 字符串(string) 父节点: error ~~~ 一个人类可读的信息,提供有关错误的详细信息。如果存在多个错误,_message_应为第一个错误的错误信息。 示例: ~~~ { "error":{ "message": "File Not Found" } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorerrors)error.errors ~~~ 属性值类型: 数组(array) 父节点: error ~~~ 包含关于错误的附加信息。如果服务返回多个错误。_errors_数组中的每个元素表示一个不同的错误。 示例: ~~~ { "error": { "errors": [] } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorerrorsdomain)error.errors[].domain ~~~ 属性值类型: 字符串(string) 父节点: error.errors ~~~ 服务抛出该错误的唯一识别符。它帮助区分服务的从普通协议错误(如,找不到文件)中区分出具体错误(例如,给日历插入事件的错误)。 示例: ~~~ { "error":{ "errors": [{"domain": "Calendar"}] } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorerrorsreason)error.errors[].reason ~~~ 属性值类型: 字符串(string) 父节点: error.errors ~~~ 该错误的唯一识别符。不同于_error.code_属性,它不是HTTP响应码。 示例: ~~~ { "error":{ "errors": [{"reason": "ResourceNotFoundException"}] } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorerrorsmessage)error.errors[].message ~~~ 属性值类型: 字符串(string) 父节点: error.errors ~~~ 一个人类可读的信息,提供有关错误的更多细节。如果只有一个错误,该字段应该与_error.message_匹配。 示例: ~~~ { "error":{ "code": 404 "message": "File Not Found", "errors": [{"message": "File Not Found"}] } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorerrorslocation)error.errors[].location ~~~ 属性值类型: 字符串(string) 父节点: error.errors ~~~ 错误发生的位置(根据_locationType_字段解释该值)。 示例: ~~~ { "error":{ "errors": [{"location": ""}] } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorerrorslocationtype)error.errors[].locationType ~~~ 属性值类型: 字符串(string) 父节点: error.errors ~~~ 标明如何解释_location_属性。 示例: ~~~ { "error":{ "errors": [{"locationType": ""}] } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorerrorsextendedhelp)error.errors[].extendedHelp ~~~ 属性值类型: 字符串(string) 父节点: error.errors ~~~ help text的URI,使错误更易于理解。 示例:(注:原示例这里有笔误,中文版这里做了校正) ~~~ { "error":{ "errors": [{"extendedHelp": "http://url.to.more.details.example.com/"}] } } ~~~ ### [](https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md#errorerrorssendreport)error.errors[].sendReport ~~~ 属性值类型: 字符串(string) 父节点: error.errors ~~~ report form的URI,服务用它来收集错误状态的数据。该URL会预先载入描述请求的参数 示例: ~~~ { "error":{ "errors": [{"sendReport": "http://report.example.com/"}] } } ~~~