Changeset 3069 in josm for trunk/src


Ignore:
Timestamp:
2010-03-02T17:16:24+01:00 (15 years ago)
Author:
Gubaer
Message:

see #4588: Open Location (Ctrl+L) should cope with certain URLs that don't lead to xml data

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java

    r2984 r3069  
    1515import org.openstreetmap.josm.Main;
    1616import org.openstreetmap.josm.io.ChangesetClosedException;
     17import org.openstreetmap.josm.io.IllegalDataException;
    1718import org.openstreetmap.josm.io.MissingOAuthAccessTokenException;
    1819import org.openstreetmap.josm.io.OsmApiException;
     
    140141                JOptionPane.ERROR_MESSAGE,
    141142                ht("/ErrorMessages#NestedIOException")
     143        );
     144    }
     145
     146    /**
     147     * Explains a {@see IllegalDataException} which has caused an {@see OsmTransferException}.
     148     * This is most likely happening when JOSM tries to load data in in an unsupported format.
     149     *
     150     * @param e the exception
     151     */
     152
     153    public static void explainNestedIllegalDataException(OsmTransferException e) {
     154        HelpAwareOptionPane.showOptionDialog(
     155                Main.parent,
     156                ExceptionUtil.explainNestedIllegalDataException(e),
     157                tr("Illegal Data"),
     158                JOptionPane.ERROR_MESSAGE,
     159                ht("/ErrorMessages#IllegalDataException")
    142160        );
    143161    }
     
    341359            return;
    342360        }
     361        if (getNestedException(e, IllegalDataException.class) != null) {
     362            explainNestedIllegalDataException(e);
     363            return;
     364        }
    343365        if (e instanceof OsmApiInitializationException) {
    344366            explainOsmApiInitializationException((OsmApiInitializationException) e);
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r3023 r3069  
    2121import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder;
    2222import org.openstreetmap.josm.io.ChangesetClosedException;
     23import org.openstreetmap.josm.io.IllegalDataException;
    2324import org.openstreetmap.josm.io.MissingOAuthAccessTokenException;
    2425import org.openstreetmap.josm.io.OsmApi;
     
    283284
    284285    /**
     286     * Explains a {@see IllegalDataException} which has caused an {@see OsmTransferException}.
     287     * This is most likely happening when JOSM tries to load data in in an unsupported format.
     288     *
     289     * @param e the exception
     290     */
     291    public static String explainNestedIllegalDataException(OsmTransferException e) {
     292        IllegalDataException ide = getNestedException(e, IllegalDataException.class);
     293        String message = tr("<html>Failed to download data."
     294                + "Its format is either unsupported, ill-formed, and/or inconsistent.<br>"
     295                + "<br>Details(untranslated): {0}</html>", ide.getMessage());
     296        e.printStackTrace();
     297        return message;
     298    }
     299
     300    /**
    285301     * Explains a {@see OsmApiException} which was thrown because of an internal server
    286302     * error in the OSM API server..
     
    306322        String apiUrl = OsmApi.getOsmApi().getBaseUrl();
    307323        String message = tr("The OSM server ''{0}'' reported a bad request.<br>", apiUrl);
    308         if (e.getErrorHeader() != null && 
    309                 (e.getErrorHeader().startsWith("The maximum bbox") || 
    310                 e.getErrorHeader().startsWith("You requested too many nodes"))) {
     324        if (e.getErrorHeader() != null &&
     325                (e.getErrorHeader().startsWith("The maximum bbox") ||
     326                        e.getErrorHeader().startsWith("You requested too many nodes"))) {
    311327            message += "<br>"
    312328                + tr("The area you tried to download is too big or your request was too large."
Note: See TracChangeset for help on using the changeset viewer.