package org.vaadin.firitin.geolocation;

public class GeolocationErrorEvent {

    /**
     * See https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPositionError
     */
    public enum GeolocationPositionError {
        UNKNOWN, PERMISSION_DENIED, POSITION_UNAVAILABLE, TIMEOUT
    }

    private int code;
    private String message;

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

    public GeolocationPositionError getError() {
        return GeolocationPositionError.values()[code];
    }

    public int getRawErrorCode() {
        return code;
    }

    public String getErrorMessage() {
        return message;
    }

    @Override
    public String toString() {
        return message.toString();
    }
}
