Xây dựng object lỗi gồm code và message luôn có. Trường details chỉ thêm vào khi chuỗi details khác rỗng. Thứ tự trường cố định: code, message, rồi details (nếu có).
Dùng từ khóa NONE (đứng riêng một dòng) để biểu thị không có details.
Input:
422
Unprocessable
email khong hop le
Output:
{"code":422,"message":"Unprocessable","details":"email khong hop le"}
Input:
500
Server Error
NONE
Output:
{"code":500,"message":"Server Error"}
Dòng 1: code. Dòng 2: message. Dòng 3: details hoặc NONE.
code 100..599. message không rỗng.
Một dòng JSON; bỏ trường details nếu input là NONE.
Ví dụ:
Đầu vào:
422
Unprocessable
email khong hop le
Đầu ra:
{"code":422,"message":"Unprocessable","details":"email khong hop le"}Giải thích:
Đang tải editor...