package com.oqpo.api.web.dto;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ExceptionDTO {
    private int status;
    private String code;
    private String message;
    private String path;
    private List<FieldError> errors;

    @Builder
    public ExceptionDTO(int status, String code, String message, String path, List<FieldError> errors) {
        this.code = code;
        this.message = message;
        this.status = status;
        this.path = path;
        this.errors = (errors == null) ? new ArrayList<>() : errors;
    }

    @Getter
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class FieldError {
        private String field;
        private String value;
        private String reason;

        @Builder
        public FieldError(String field, String value, String reason) {
            this.field = field;
            this.value = value;
            this.reason = reason;
        }
    }
}
