Ignore:
Timestamp:
2009-11-19T13:30:09+01:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3937: Closed changeset (due to timeout) remains in the upload dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r2387 r2480  
    1414import java.text.SimpleDateFormat;
    1515import java.util.Date;
     16import java.util.Locale;
    1617import java.util.regex.Matcher;
    1718import java.util.regex.Pattern;
    1819
    1920import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.io.ChangesetClosedException;
    2022import org.openstreetmap.josm.io.OsmApi;
    2123import org.openstreetmap.josm.io.OsmApiException;
    2224import org.openstreetmap.josm.io.OsmApiInitializationException;
    23 import org.openstreetmap.josm.io.OsmChangesetCloseException;
    2425import org.openstreetmap.josm.io.OsmTransferException;
    2526
     
    3940                + "Check the server URL in your preferences and your internet connection.</html>", Main.pref.get(
    4041                        "osm-server.url", "http://api.openstreetmap.org/api"));
    41         return msg;
    42     }
    43 
    44     /**
    45      * handles an exception caught during OSM API initialization
    46      *
    47      * @param e the exception
    48      */
    49     public static String explainOsmChangesetCloseException(OsmChangesetCloseException e) {
    50         e.printStackTrace();
    51         String changsetId = e.getChangeset() == null ? tr("unknown") : Long.toString(e.getChangeset().getId());
    52         String msg = tr(
    53                 "<html>Failed to close changeset ''{0}'' on the OSM server ''{1}''.<br>"
    54                 + "The changeset will automatically be closed by the server after a timeout.</html>", changsetId,
    55                 Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api"));
    5642        return msg;
    5743    }
     
    115101            if (m.matches()) {
    116102                long changesetId = Long.parseLong(m.group(1));
    117                 // Example: Tue Oct 15 10:00:00 UTC 2009
    118                 DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
     103                // Example: Tue Oct 15 10:00:00 UTC 2009. Always parsed with english locale, regardless
     104                // of the current locale in JOSM
     105                DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
    119106                Date closeDate = null;
    120107                try {
     
    153140
    154141    /**
     142     * Explains an exception thrown during upload because the changeset which data is
     143     * uploaded to is already closed.
     144     *
     145     * @param e the exception
     146     */
     147    public static String explainChangesetClosedException(ChangesetClosedException e) {
     148        String msg;
     149        SimpleDateFormat dateFormat = new SimpleDateFormat();
     150        msg = tr(
     151                "<html>Failed to upload to changeset <strong>{0}</strong><br>"
     152                +"because it has already been closed on {1}.</html>",
     153                e.getChangesetId(),
     154                dateFormat.format(e.getClosedOn())
     155        );
     156        e.printStackTrace();
     157        return msg;
     158    }
     159
     160    /**
    155161     * Explains an exception with a generic message dialog
    156162     *
     
    338344        if (e instanceof OsmApiInitializationException)
    339345            return explainOsmApiInitializationException((OsmApiInitializationException) e);
    340         if (e instanceof OsmChangesetCloseException)
    341             return explainOsmChangesetCloseException((OsmChangesetCloseException) e);
     346
     347        if (e instanceof ChangesetClosedException)
     348            return explainChangesetClosedException((ChangesetClosedException)e);
    342349
    343350        if (e instanceof OsmApiException) {
Note: See TracChangeset for help on using the changeset viewer.