
package au.id.hazelwood.idms.web.dto.error;

import au.id.hazelwood.idms.web.dto.framework.BaseDto;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public final class ErrorDto extends BaseDto
{
    private final Integer code;
    private final String message;
    private final List<ErrorInfoDto> errors;

    public ErrorDto(ErrorType type, ErrorInfoDto... errors)
    {
        this(type, Arrays.asList(errors));
    }

    public ErrorDto(ErrorType type, List<ErrorInfoDto> errors)
    {
        this.code = type.getCode();
        this.message = type.getMessage();
        this.errors = Collections.unmodifiableList(errors);
    }

    public Integer getCode()
    {
        return code;
    }

    public String getMessage()
    {
        return message;
    }

    public List<ErrorInfoDto> getErrors()
    {
        return errors;
    }
}
