Changeset 13388 in josm


Ignore:
Timestamp:
2018-02-07T00:16:59+01:00 (6 years ago)
Author:
Don-vip
Message:

see #15880 - robustness to unsupported projections

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

Legend:

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

    r13252 r13388  
    4040import org.openstreetmap.josm.tools.ImageProvider;
    4141import org.openstreetmap.josm.tools.Logging;
     42import org.openstreetmap.josm.tools.bugreport.ReportedException;
    4243
    4344/**
     
    136137    public void actionPerformed(ActionEvent e) {
    137138        if (!isEnabled()) return;
     139        ImageryLayer layer = null;
    138140        try {
    139141            final ImageryInfo infoToAdd = convertImagery(info);
    140142            if (infoToAdd != null) {
    141                 getLayerManager().addLayer(ImageryLayer.create(infoToAdd));
     143                layer = ImageryLayer.create(infoToAdd);
     144                getLayerManager().addLayer(layer);
    142145                AlignImageryPanel.addNagPanelIfNeeded(infoToAdd);
    143146            }
    144         } catch (IllegalArgumentException ex) {
     147        } catch (IllegalArgumentException | ReportedException ex) {
    145148            if (ex.getMessage() == null || ex.getMessage().isEmpty() || GraphicsEnvironment.isHeadless()) {
    146149                throw ex;
    147150            } else {
    148                 JOptionPane.showMessageDialog(Main.parent,
    149                         ex.getMessage(), tr("Error"),
    150                         JOptionPane.ERROR_MESSAGE);
     151                Logging.error(ex);
     152                JOptionPane.showMessageDialog(Main.parent, ex.getMessage(), tr("Error"), JOptionPane.ERROR_MESSAGE);
     153                if (layer != null) {
     154                    getLayerManager().removeLayer(layer);
     155                }
    151156            }
    152157        }
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r13387 r13388  
    147147            identifier = builder.identifier;
    148148        }
     149
     150        @Override
     151        public String toString() {
     152            return "TileMatrixSet [crs=" + crs + ", identifier=" + identifier + ']';
     153        }
    149154    }
    150155
     
    188193        public String getUserTitle() {
    189194            return title != null ? title : identifier;
     195        }
     196
     197        @Override
     198        public String toString() {
     199            return "Layer [identifier=" + identifier + ", title=" + title + ", tileMatrixSet="
     200                    + tileMatrixSet + ", baseUrl=" + baseUrl + ", style=" + style + ']';
    190201        }
    191202    }
     
    683694                }
    684695                if (this.currentLayer == null)
    685                     return;
     696                    throw new IllegalArgumentException(
     697                            layers.stream().map(l -> l.tileMatrixSet).collect(Collectors.toList()).toString());
    686698            } // else: keep currentLayer and tileProjection as is
    687699        }
Note: See TracChangeset for help on using the changeset viewer.