Kết hợp nhiều khái niệm: từ input dựng một báo cáo lỗi JSON gồm các trường theo thứ tự cố định: correlationId, timestamp, status, code, message, retryable.
Quy tắc:
status map từ tên exception theo bảng: ValidationError->400, AuthError->401, NotFoundError->404, còn lại->500.code là chuỗi: tên exception viết HOA toàn bộ, dấu giữa các từ camelCase chuyển thành _. Ví dụ NotFoundError -> NOT_FOUND_ERROR.retryable = true nếu status >= 500, ngược lại false.timestamp lấy nguyên từ input.Input:
abc-1
2026-07-01T08:00:00Z
NotFoundError
User khong ton tai
Output:
{"correlationId":"abc-1","timestamp":"2026-07-01T08:00:00Z","status":404,"code":"NOT_FOUND_ERROR","message":"User khong ton tai","retryable":false}
Dòng 1: correlationId. Dòng 2: timestamp. Dòng 3: tên exception (CamelCase). Dòng 4: message.
Tên exception là chữ cái CamelCase. message không rỗng.
Một dòng JSON với thứ tự trường correlationId, timestamp, status, code, message, retryable.
Ví dụ:
Đầu vào:
abc-1
2026-07-01T08:00:00Z
NotFoundError
User khong ton tai
Đầu ra:
{"correlationId":"abc-1","timestamp":"2026-07-01T08:00:00Z","status":404,"code":"NOT_FOUND_ERROR","message":"User khong ton tai","retryable":false}Giải thích:
Đang tải editor...