您目前查看的是 Google Photos Library API 的舊版說明文件。
Status
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Status
類型會定義適用於不同程式設計環境 (包含 REST API 和遠端程序呼叫 (RPC) API) 的邏輯錯誤模型。gRPC 會使用這個模型。每個 Status
訊息包含三部分的資料:錯誤代碼、錯誤訊息和錯誤詳細資料。
如要進一步瞭解這個錯誤模型,以及如何使用這個錯誤模型,請參閱 API 設計指南。
JSON 表示法 |
{
"code": integer,
"message": string,
"details": [
{
"@type": string,
field1: ...,
...
}
]
} |
欄位 |
code |
integer
狀態碼,應為 google.rpc.Code 的列舉值。
|
message |
string
向開發人員顯示的錯誤訊息,應以英文呈現。凡是向使用者顯示的錯誤訊息,都應透過 google.rpc.Status.details 欄位進行本地化並傳送,或由用戶端進行本地化。
|
details[] |
object
附有錯誤詳細資料的訊息清單。這是供 API 使用的一組常用訊息類型。 包含任意類型欄位的物件。額外的 "@type" 欄位則包含能辨識類型的 URI。範例:{ "id": 1234, "@type": "types.example.com/standard/id" } 。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003eStatus\u003c/code\u003e type is a structured approach to representing errors in APIs, suitable for REST and RPC.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eStatus\u003c/code\u003e object contains the error code (\u003ccode\u003einteger\u003c/code\u003e), an English error message (\u003ccode\u003estring\u003c/code\u003e), and an optional array of objects with error details (\u003ccode\u003edetails\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003edetails\u003c/code\u003e object includes an \u003ccode\u003e@type\u003c/code\u003e field with a URI to specify the type of error, enabling flexible representation.\u003c/p\u003e\n"]]],["The `Status` type represents a logical error model with three data components: `code`, `message`, and `details`. `code` is an integer representing the status code. `message` is a developer-facing error string, preferably in English. `details` is a list of objects that convey detailed error information, each with a `\"@type\"` field to identify its type. It is designed for various environments, like REST and RPC APIs, and is used by gRPC.\n"],null,["# Status\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n\nThe `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------|\n| ``` { \"code\": integer, \"message\": string, \"details\": [ { \"@type\": string, field1: ..., ... } ] } ``` |\n\n| Fields ||\n|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `code` | `integer` The status code, which should be an enum value of `google.rpc.Code`. |\n| `message` | `string` A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details](/photos/library/legacy/reference/rest/v1/Status#FIELDS.details) field, or localized by the client. |\n| `details[]` | `object` A list of messages that carry the error details. There is a common set of message types for APIs to use. An object containing fields of an arbitrary type. An additional field `\"@type\"` contains a URI identifying the type. Example: `{ \"id\": 1234, \"@type\": \"types.example.com/standard/id\" }`. |"]]