Changeset 1608 in josm


Ignore:
Timestamp:
2009-05-23T11:36:04+02:00 (15 years ago)
Author:
stoecker
Message:

close #2633 - patch by Gubaer - better error message for server aborts

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r1581 r1608  
    129129    /**
    130130     * Initializes this component by negotiating a protocol version with the server.
    131      */
    132     public void initialize() {
     131     *
     132     * @exception UnknownHostException thrown, if the API host is unknown
     133     * @exception SocketTimeoutException thrown, if the connection to the API host  times out
     134     * @exception ConnectException throw, if the connection to the API host fails
     135     * @exception Exception any other exception
     136     */
     137    public void initialize() throws UnknownHostException,SocketTimeoutException, ConnectException,Exception {
    133138        initAuthentication();
    134139        try {
     
    153158        } catch (Exception ex) {
    154159            initialized = false;
    155             ex.printStackTrace();
     160            throw ex;
    156161        }
    157162    }
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r1523 r1608  
    1111import java.util.zip.InflaterInputStream;
    1212import java.util.zip.GZIPInputStream;
     13
     14import javax.swing.JOptionPane;
    1315
    1416import org.openstreetmap.josm.Main;
     
    3840     */
    3941    protected InputStream getInputStream(String urlStr, PleaseWaitDialog pleaseWaitDlg) throws IOException {
    40         api.initialize();
     42       
     43        // initialize API. Abort download in case of configuration or network
     44        // errors
     45        //
     46        try {
     47            api.initialize();
     48        } catch(Exception e) {
     49            JOptionPane.showMessageDialog(
     50                null,
     51                tr(   "Failed to initialize communication with the OSM server {0}.\n"
     52                    + "Check the server URL in your preferences and your internet connection.",
     53                    Main.pref.get("osm-server.url")
     54                ),
     55                tr("Error"),
     56                JOptionPane.ERROR_MESSAGE
     57            );
     58            e.printStackTrace();
     59            return null;
     60        }
     61
    4162        urlStr = api.getBaseUrl() + urlStr;
    4263        return getInputStreamRaw(urlStr, pleaseWaitDlg);
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r1581 r1608  
    6868    public void uploadOsm(String the_version, Collection<OsmPrimitive> list) {
    6969        processed = new LinkedList<OsmPrimitive>();
    70         api.initialize();
     70       
     71        // initialize API. Abort upload in case of configuration or network
     72        // errors
     73        //
     74        try {
     75            api.initialize();
     76        } catch(Exception e) {
     77            JOptionPane.showMessageDialog(
     78                null,
     79                tr(   "Failed to initialize communication with the OSM server {0}.\n"
     80                    + "Check the server URL in your preferences and your internet connection.",
     81                    Main.pref.get("osm-server.url")
     82                ),
     83                tr("Error"),
     84                JOptionPane.ERROR_MESSAGE
     85            );
     86            e.printStackTrace();
     87            return;
     88        }
     89       
    7190
    7291        Main.pleaseWaitDlg.progress.setMaximum(list.size());
Note: See TracChangeset for help on using the changeset viewer.