Changeset 2201 in josm


Ignore:
Timestamp:
Sep 27, 2009 5:28:08 PM (4 years ago)
Author:
Gubaer
Message:

fixed #2818: error when retrieving map data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r1835 r2201  
    1212import org.openstreetmap.josm.actions.DownloadAction; 
    1313import org.openstreetmap.josm.data.gpx.GpxData; 
     14import org.openstreetmap.josm.gui.ExceptionDialogUtil; 
    1415import org.openstreetmap.josm.gui.PleaseWaitRunnable; 
    1516import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; 
     
    2829        private GpxData rawData; 
    2930        private final boolean newLayer; 
     31        private OsmTransferException lastException; 
    3032 
    3133        public Task(boolean newLayer, BoundingBoxDownloader reader, ProgressMonitor progressMonitor) { 
     
    3638 
    3739        @Override public void realRun() throws IOException, SAXException, OsmTransferException { 
    38             rawData = reader.parseRawGps(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 
     40            try { 
     41                rawData = reader.parseRawGps(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 
     42            } catch(OsmTransferException e) { 
     43                lastException = e; 
     44            } catch(Exception e) { 
     45                lastException = new OsmTransferException(e); 
     46            } 
    3947        } 
    4048 
    4149        @Override protected void finish() { 
     50            if (lastException != null) { 
     51                ExceptionDialogUtil.explainException(lastException); 
     52                return; 
     53            } 
    4254            if (rawData == null) 
    4355                return; 
     
    4658            GpxLayer layer = new GpxLayer(rawData, name); 
    4759            Layer x = findMergeLayer(); 
    48             if (newLayer || x == null) 
     60            if (newLayer || x == null) { 
    4961                Main.main.addLayer(layer); 
    50             else 
     62            } else { 
    5163                x.mergeFrom(layer); 
     64            } 
    5265        } 
    5366 
     
    6679 
    6780        @Override protected void cancel() { 
    68             if (reader != null) 
     81            if (reader != null) { 
    6982                reader.cancel(); 
     83            } 
    7084        } 
    7185    } 
     
    105119            Task t = task.get(); 
    106120            return t.getProgressMonitor().getErrorMessage() == null 
    107                 ? "" 
    108                 : t.getProgressMonitor().getErrorMessage(); 
     121            ? "" 
     122                    : t.getProgressMonitor().getErrorMessage(); 
    109123        } catch (Exception e) { 
    110124            return ""; 
Note: See TracChangeset for help on using the changeset viewer.