Xử lý lỗi
Sử dụng mã trạng thái 400 Bad Request
cho tất cả các lỗi được xác định trong quy cách này. Đối với tất cả các lỗi khác, nhà sản xuất nên sử dụng phạm vi lỗi trong phạm vi 4XX cho lỗi ứng dụng và phạm vi 5XX cho lỗi máy chủ. Phản hồi phải luôn chứa nội dung JSON ở định dạng sau cho mọi trường hợp lỗi:
{
"name": "camera.info",
"state": "error",
"error": {
"code": "serverError",
"message": "cannot get camera info."
}
}
name
có thể là bất kỳ giá trị nào trong số camera.info
, camera.state
, camera.checkForUpdates
,
camera.commands.status
và camera.commandName
.
code
phải là một trong các giá trị sau cho mã trạng thái 400:unknownCommand
,
cameraInExclusiveUse
, missingParameter
, invalidParameterName
hoặc
invalidParameterValue
.
message
do các nhà sản xuất xác định và dự kiến sẽ không được bản địa hoá
.
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: 2024-08-21 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2024-08-21 UTC."],[[["Always use the `400 Bad Request` status code for errors defined in the specification and appropriate 4XX or 5XX codes for other client or server errors, respectively."],["All error responses must include a JSON body with `name`, `state`, and an `error` object containing `code` and `message`."],["The `error.code` field uses predefined values for 400 errors (`unknownCommand`, `cameraInExclusiveUse`, `missingParameter`, `invalidParameterName`, `invalidParameterValue`) while manufacturers define the `error.message`."],["The `name` field identifies the specific request, such as `camera.info` or `camera.commands.status`, associated with the error."]]],["Error responses must include a JSON body with \"name,\" \"state,\" and \"error\" fields. For specified errors, use the `400 Bad Request` status code, otherwise, employ 4XX for client and 5XX for server errors. The \"name\" field can be one of several camera-related identifiers. \"Code\" within the error object must be one of five predefined error codes for 400 responses. The \"message\" field is free-form, manufacturer-defined, and non-localized.\n"]]