Package google.rpc
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
狀態
Status
類型會定義適用於不同程式設計環境 (包含 REST API 和遠端程序呼叫 (RPC) API) 的邏輯錯誤模型。gRPC 會使用這個模型。每個 Status
訊息包含三部分的資料:錯誤代碼、錯誤訊息和錯誤詳細資料。
如要進一步瞭解這個錯誤模型,以及如何使用這個錯誤模型,請參閱 API 設計指南。
欄位 |
code |
int32
狀態碼,應為 google.rpc.Code 的列舉值。
|
message |
string
向開發人員顯示的錯誤訊息,應以英文呈現。所有向使用者顯示的錯誤訊息都應經過本地化,並透過 google.rpc.Status.details 欄位傳送,或是由用戶端加以本地化。
|
details[] |
Any
附有錯誤詳細資料的訊息清單。這是供 API 使用的一組常用訊息類型。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003eStatus\u003c/code\u003e type defines a logical error model suitable for various programming environments, including REST and RPC APIs, and is used by gRPC.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eStatus\u003c/code\u003e message consists of three components: an error code, an error message, and error details.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecode\u003c/code\u003e field represents the status code and is expected to be an enum value of \u003ccode\u003egoogle.rpc.Code\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003emessage\u003c/code\u003e field provides a developer-facing error message in English, while user-facing messages should be localized.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edetails[]\u003c/code\u003e field is a list of messages that carry error details, utilizing a set of common message types for APIs.\u003c/p\u003e\n"]]],[],null,["# Package google.rpc\n\nIndex\n-----\n\n- [Status](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.rpc#google.rpc.Status) (message)\n\nStatus\n------\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| Fields ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `code` | `int32` 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](/maps/tt/route-optimization/experimental/otlr/reference/rpc/google.rpc#google.rpc.Status.FIELDS.repeated.google.protobuf.Any.google.rpc.Status.details) field, or localized by the client. |\n| `details[]` | [Any](https://protobuf.dev/reference/protobuf/google.protobuf/#any) A list of messages that carry the error details. There is a common set of message types for APIs to use. |"]]