Index: trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java	(revision 14549)
+++ trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java	(revision 14550)
@@ -225,5 +225,15 @@
      */
     protected static ImageryInfo getWMSLayerInfo(ImageryInfo info) throws IOException, WMSGetCapabilitiesException {
-        return getWMSLayerInfo(info, AddImageryLayerAction::askToSelectLayers);
+        try {
+            return getWMSLayerInfo(info, AddImageryLayerAction::askToSelectLayers);
+        } catch (MalformedURLException ex) {
+            handleException(ex, tr("Invalid service URL."), tr("WMS Error"), null);
+        } catch (IOException ex) {
+            handleException(ex, tr("Could not retrieve WMS layer list."), tr("WMS Error"), null);
+        } catch (WMSGetCapabilitiesException ex) {
+            handleException(ex, tr("Could not parse WMS layer list."), tr("WMS Error"),
+                    "Could not parse WMS layer list. Incoming data:\n" + ex.getIncomingData());
+        }
+        return null;
     }
 
@@ -240,38 +250,28 @@
     public static ImageryInfo getWMSLayerInfo(ImageryInfo info, Function<WMSImagery, LayerSelection> choice)
             throws IOException, WMSGetCapabilitiesException {
-        try {
-            CheckParameterUtil.ensureThat(ImageryType.WMS_ENDPOINT == info.getImageryType(), "wms_endpoint imagery type expected");
-            final WMSImagery wms = new WMSImagery(info.getUrl(), info.getCustomHttpHeaders());
-            LayerSelection selection = choice.apply(wms);
-            if (selection == null) {
-                return null;
-            }
-
-            final String url = wms.buildGetMapUrl(
-                    selection.layers.stream().map(LayerDetails::getName).collect(Collectors.toList()),
-                    (List<String>) null,
-                    selection.format,
-                    selection.transparent
-                    );
-
-            String selectedLayers = selection.layers.stream()
-                    .map(LayerDetails::getName)
-                    .collect(Collectors.joining(", "));
-            // Use full copy of original Imagery info to copy all attributes. Only overwrite what's different
-            ImageryInfo ret = new ImageryInfo(info);
-            ret.setUrl(url);
-            ret.setImageryType(ImageryType.WMS);
-            ret.setName(info.getName() + selectedLayers);
-            ret.setServerProjections(wms.getServerProjections(selection.layers));
-            return ret;
-        } catch (MalformedURLException ex) {
-            handleException(ex, tr("Invalid service URL."), tr("WMS Error"), null);
-        } catch (IOException ex) {
-            handleException(ex, tr("Could not retrieve WMS layer list."), tr("WMS Error"), null);
-        } catch (WMSGetCapabilitiesException ex) {
-            handleException(ex, tr("Could not parse WMS layer list."), tr("WMS Error"),
-                    "Could not parse WMS layer list. Incoming data:\n" + ex.getIncomingData());
-        }
-        return null;
+        CheckParameterUtil.ensureThat(ImageryType.WMS_ENDPOINT == info.getImageryType(), "wms_endpoint imagery type expected");
+        final WMSImagery wms = new WMSImagery(info.getUrl(), info.getCustomHttpHeaders());
+        LayerSelection selection = choice.apply(wms);
+        if (selection == null) {
+            return null;
+        }
+
+        final String url = wms.buildGetMapUrl(
+                selection.layers.stream().map(LayerDetails::getName).collect(Collectors.toList()),
+                (List<String>) null,
+                selection.format,
+                selection.transparent
+                );
+
+        String selectedLayers = selection.layers.stream()
+                .map(LayerDetails::getName)
+                .collect(Collectors.joining(", "));
+        // Use full copy of original Imagery info to copy all attributes. Only overwrite what's different
+        ImageryInfo ret = new ImageryInfo(info);
+        ret.setUrl(url);
+        ret.setImageryType(ImageryType.WMS);
+        ret.setName(info.getName() + selectedLayers);
+        ret.setServerProjections(wms.getServerProjections(selection.layers));
+        return ret;
     }
 
