Changeset 3101 in josm for trunk/src/org


Ignore:
Timestamp:
2010-03-09T14:00:46+01:00 (14 years ago)
Author:
Gubaer
Message:

fixed #4684: HTTP 408 gives coding error popup

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

Legend:

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

    r3083 r3101  
    282282
    283283    /**
     284     * Explains a {@see OsmApiException} which was thrown because of a
     285     * client timeout (HTTP 408)
     286     *
     287     * @param e the exception
     288     */
     289    public static void explainClientTimeout(OsmApiException e) {
     290        HelpAwareOptionPane.showOptionDialog(
     291                Main.parent,
     292                ExceptionUtil.explainClientTimeout(e),
     293                tr("Client Time Out"),
     294                JOptionPane.ERROR_MESSAGE,
     295                ht("/ErrorMessages#ClientTimeOut")
     296        );
     297    }
     298
     299    /**
     300     * Explains a {@see OsmApiException} with a generic error
     301     * message.
     302     *
     303     * @param e the exception
     304     */
     305    public static void explainGenericHttpException(OsmApiException e) {
     306        HelpAwareOptionPane.showOptionDialog(
     307                Main.parent,
     308                ExceptionUtil.explainClientTimeout(e),
     309                tr("Communication with OSM server failed"),
     310                JOptionPane.ERROR_MESSAGE,
     311                ht("/ErrorMessages#GenericCommunicationError")
     312        );
     313    }
     314
     315    /**
    284316     * Explains a {@see OsmApiException} which was thrown because accessing a protected
    285317     * resource was forbidden.
     
    405437                explainAuthorizationFailed(oae);
    406438                return;
     439            case HttpURLConnection.HTTP_CLIENT_TIMEOUT:
     440                explainClientTimeout(oae);
     441                return;
     442            default:
     443                explainGenericHttpException(oae);
     444                return;
    407445            }
    408446        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r3099 r3101  
    118118
    119119        JPanel buttonPanel = getButtonPanel(2);
    120         //
    121         //        selectButton = new SideButton(marktr("Select"), "select", "SelectionList",
    122         //                tr("Set the selected elements on the map to the selected items in the list above."),
    123         //                new ActionListener() {
    124         //            public void actionPerformed(ActionEvent e) {
    125         //                updateMap();
    126         //            }
    127         //        });
    128120        selectButton = new SideButton(actSelect = new SelectAction());
    129121        buttonPanel.add(selectButton);
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r3083 r3101  
    141141        );
    142142    }
     143
     144    /**
     145     * Explains an OSM API exception because of a client timeout (HTTP 408).
     146     *
     147     * @param e the exception
     148     * @return the message
     149     */
     150    public static String explainClientTimeout(OsmApiException e) {
     151        e.printStackTrace();
     152        return tr("<html>"
     153                + "Communication with the OSM server ''{0}'' timed out. Please retry later."
     154                + "</html>",
     155                OsmApi.getOsmApi().getBaseUrl()
     156        );
     157    }
     158
     159    /**
     160     * Replies a generic error message for an OSM API exception
     161     *
     162     * @param e the exception
     163     * @return the message
     164     */
     165    public static String explainGenericOsmApiException(OsmApiException e) {
     166        e.printStackTrace();
     167        String errMsg = e.getErrorHeader();
     168        if (errMsg == null) {
     169            errMsg = e.getErrorBody();
     170        }
     171        if (errMsg == null) {
     172            errMsg = tr("no error message available");
     173        }
     174        return tr("<html>"
     175                + "Communication with the OSM server ''{0}''failed. The server replied<br>"
     176                + "the following error code and the following error message:<br>"
     177                + "<strong>Error code:<strong> {1}<br>"
     178                + "<strong>Error message (untranslated)</strong>: {2}"
     179                + "</html>",
     180                OsmApi.getOsmApi().getBaseUrl(),
     181                e.getResponseCode(),
     182                errMsg
     183        );
     184    }
     185
    143186    /**
    144187     * Explains an error due to a 409 conflict
Note: See TracChangeset for help on using the changeset viewer.