package com.its.op.exception; import lombok.Builder; import lombok.Getter; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @Getter public class ErrorResponse { private LocalDateTime timestamp; private final int status; private String title; private final String message; private List errors; @Builder public ErrorResponse(LocalDateTime timestamp, int status, String title, String message, List errors) { this.timestamp = timestamp; this.status = status; this.title = title; this.message = message; this.errors = errors;//initErrors(errors); } private List initErrors(List errors) { return (errors == null) ? new ArrayList<>() : errors; } /* public static ErrorResponse buildError(ErrorCode errorCode) { return ErrorResponse.builder() .code(errorCode.getCode()) .message(errorCode.getMessage()) .build(); }*/ @Getter public static class FieldError { private final String field; private final String value; private final String reason; @Builder public FieldError(String field, String value, String reason) { this.field = field; this.value = value; this.reason = reason; } } }