Status
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Loại Status
xác định mô hình lỗi logic phù hợp với nhiều môi trường lập trình, bao gồm cả API REST và API RPC. Hàm này được gRPC sử dụng. Mỗi thông báo Status
chứa 3 phần dữ liệu: mã lỗi, thông báo lỗi và thông tin chi tiết về lỗi.
Bạn có thể tìm hiểu thêm về mô hình lỗi này cũng như cách xử lý trong Hướng dẫn thiết kế API.
Biểu diễn dưới dạng JSON |
{
"code": integer,
"message": string,
"details": [
{
"@type": string,
field1: ...,
...
}
]
} |
Trường |
code |
integer
Mã trạng thái, phải là một giá trị enum của google.rpc.Code .
|
message |
string
Thông báo lỗi dành cho nhà phát triển, phải bằng tiếng Anh. Mọi thông báo lỗi dành cho người dùng đều phải được bản địa hoá và gửi trong trường google.rpc.Status.details hoặc để ứng dụng bản địa hoá.
|
details[] |
object
Danh sách các thông báo chứa thông tin chi tiết về lỗi. Có một nhóm loại thông báo phổ biến để API sử dụng. Một đối tượng có chứa các trường thuộc loại tuỳ ý. Trường bổ sung "@type" chứa URI xác định kiểu. Ví dụ: { "id": 1234, "@type": "types.example.com/standard/id" } .
|
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eStatus\u003c/code\u003e type is a standard error model used by gRPC and REST APIs to represent errors with a code, message, and optional details.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eStatus\u003c/code\u003e object includes an integer \u003ccode\u003ecode\u003c/code\u003e from \u003ccode\u003egoogle.rpc.Code\u003c/code\u003e, a developer-facing \u003ccode\u003emessage\u003c/code\u003e, and an array of \u003ccode\u003edetails\u003c/code\u003e for further information.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edetails\u003c/code\u003e field allows for structured error data using custom types identified by a \u003ccode\u003e@type\u003c/code\u003e URI.\u003c/p\u003e\n"]]],["The `Status` type represents a logical error model with three data components: `code`, `message`, and `details`. `code` is an integer status code, `message` is a developer-facing English error message, and `details` is a list of objects providing further error information, each specifying its type via `\"@type\"`. The JSON representation uses these fields to structure error messages. User-facing messages should be localized.\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](/streetview/publish/reference/rest/v1/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](/streetview/publish/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\" }`. |"]]