package ltd.qubit.survey.model; import lombok.Data; /** * 错误信息 */ @Data public class ErrorInfo { /** * 错误代码 */ private String code; /** * 错误消息 */ private String message; /** * 错误详情 */ private String detail; /** * 时间戳 */ private long timestamp; /** * 请求路径 */ private String path; /** * 创建错误信息 * * @param code 错误代码 * @param message 错误消息 * @param detail 错误详情 * @param path 请求路径 * @return 错误信息 */ public static ErrorInfo of(String code, String message, String detail, String path) { ErrorInfo error = new ErrorInfo(); error.setCode(code); error.setMessage(message); error.setDetail(detail); error.setPath(path); error.setTimestamp(System.currentTimeMillis()); return error; } /** * 创建错误信息(无详情) * * @param code 错误代码 * @param message 错误消息 * @param path 请求路径 * @return 错误信息 */ public static ErrorInfo of(String code, String message, String path) { return of(code, message, null, path); } }