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

import java.util.HashMap;
import java.util.Map;

public enum ErrorCode {
    SUCCESS              (0,"요청성공"),
    UNREGISTERED_APITOKEN(1,"등록되지 않은 API TOKEN"),
    APITOKEN_EXPIRED     (2,"API TOKEN 유효기간 오류"),
    DENIED_IPADDR        (3,"접근불가 IP Address"),
    NOTFOUND_BROKER_INFO (4,"접속 가능한 브로커 정보가 없음"),
    NOTFOUND_URL         (5,"잘못된 URL 경로"),
    ERROR_INTERNAL_DATA  (6,"내부 데이터 오류"),
    NOT_AVAILABLE        (7,"현재 사용할수 없음"),
    PENDING_REGISTRATION (8,"등록 대기 중");

    private final int code;
    private final String message;
    private static final Map<Integer, ErrorCode> map;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    static {
        map = new HashMap<>();
        for (ErrorCode e : values())
            map.put(e.code, e);
    }

    public static ErrorCode getValue(int code) {
        // FOR KISA Secure Coding pass
        //return map.get(code);
        ErrorCode error = map.get(code);
        return error;
    }
}
