package egovframework.com.its.web.server.exception;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

import java.time.LocalDateTime;
import java.util.List;

@Getter
@ToString
public class ErrorResponse {


    private final LocalDateTime timestamp;
    private final int status;
    private final String title;
    private final String message;
    private final String path;
    private final List<String> errors;

    @Builder
    public ErrorResponse(LocalDateTime timestamp, int status, String title, String message, String path, List<String> errors) {
        this.timestamp = timestamp;
        this.status    = status;
        this.title     = title;
        this.message   = message;
        this.path      = path;
        // FOR KISA Secure Coding pass
        List<String> errList = errors;
        this.errors = errList;
    }

    @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;
        }
    }
}
