Changeset 14442 in josm


Ignore:
Timestamp:
2018-11-22T00:50:48+01:00 (5 months ago)
Author:
Don-vip
Message:

fix #17016 - catch error when entering bad WMS URL

File:
1 edited

Legend:

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

    r14397 r14442  
    232232    /**
    233233     * Adds a WMS Layer with given title and URL
    234      * @param title Name of the layer as it will shop up in the layer manager
     234     * @param title Name of the layer as it will show up in the layer manager
    235235     * @param url URL to the WMS server
    236236     * @throws IllegalStateException if imagery time is neither HTML nor WMS
     
    242242                info = AddImageryLayerAction.getWMSLayerInfo(info);
    243243            } catch (IOException | WMSGetCapabilitiesException e) {
    244                 Logging.error(e);
    245                 JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    246                         e.getMessage(), tr("No valid WMS URL or id"), JOptionPane.ERROR_MESSAGE);
     244                handleException(e);
    247245                return;
    248246            }
    249247        }
    250         MainApplication.getLayerManager().addLayer(ImageryLayer.create(info));
     248        try {
     249            MainApplication.getLayerManager().addLayer(ImageryLayer.create(info));
     250        } catch (IllegalArgumentException e) {
     251            handleException(e);
     252        }
     253    }
     254
     255    private static void handleException(Exception e) {
     256        Logging.error(e);
     257        JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
     258                e.getMessage(), tr("No valid WMS URL or id"), JOptionPane.ERROR_MESSAGE);
    251259    }
    252260
Note: See TracChangeset for help on using the changeset viewer.