处理请求错误
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Routes API 会在对方法调用的响应中返回错误消息。例如,如果您从请求中省略 API 密钥,该方法会返回:
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"
}
}
如果您省略了必需的正文参数(例如 origin
),该方法会返回:
{
"error": {
"code": 400,
"message": "Origin and destination must be set.",
"status": "INVALID_ARGUMENT"
}
}
如需详细了解错误和错误处理,请参阅错误。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-06-20。
[null,null,["最后更新时间 (UTC):2025-06-20。"],[[["\u003cp\u003eThe Routes API provides error messages within its responses to indicate issues with the request.\u003c/p\u003e\n"],["\u003cp\u003eErrors are returned as JSON objects containing an \u003ccode\u003eerror\u003c/code\u003e field with details about the issue, such as a code, message, and status.\u003c/p\u003e\n"],["\u003cp\u003eMissing API keys result in a \u003ccode\u003ePERMISSION_DENIED\u003c/code\u003e error with a 403 code.\u003c/p\u003e\n"],["\u003cp\u003eOmitting required parameters like \u003ccode\u003eorigin\u003c/code\u003e leads to an \u003ccode\u003eINVALID_ARGUMENT\u003c/code\u003e error with a 400 code.\u003c/p\u003e\n"],["\u003cp\u003eFurther details on errors and their handling can be found in the Google Cloud API Design Guide on Errors.\u003c/p\u003e\n"]]],[],null,[]]