package in.gov.digilocker.uidai.services.properties;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.springframework.stereotype.Service;

@Service
public class UidaiErrors {
	
	private Map<String, String> errorMap;

	public UidaiErrors() {
		Properties uidaiErrorProp = new java.util.Properties();
		try {
			InputStream uidaiInputStream = getClass().getClassLoader().getResourceAsStream("uidai-error-list.properties");
			uidaiErrorProp.load(uidaiInputStream);
		} catch (Exception e) {
			throw new RuntimeException(e.getMessage());
		}
		this.errorMap = new HashMap<>();
		for (String key : uidaiErrorProp.stringPropertyNames()) {
		    String value = uidaiErrorProp.getProperty(key);
		    this.errorMap.put(key, String.valueOf(value));
		}
	}

	public Map<String, String> getErrorMap() {
		return errorMap;
	}

	public void setErrorMap(Map<String, String> errorMap) {
		this.errorMap = errorMap;
	}
	
	
}