001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.io;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006/**
007 * Exception thrown when an online resource is accessed while in offline mode.
008 * @since 7434
009 */
010public class OfflineAccessException extends IllegalStateException {
011
012    /**
013     * Constructs a new {@code OfflineAccessException}.
014     * @param s the String that contains a detailed message
015     */
016    public OfflineAccessException(String s) {
017        super(s);
018    }
019
020    /**
021     * Returns a new OfflineAccessException with a translated message for the given resource
022     * @param name the translated name/description of the resource
023     * @return a new OfflineAccessException
024     */
025    public static OfflineAccessException forResource(String name) {
026        return new OfflineAccessException(tr("{0} not available (offline mode)", name));
027    }
028}