Changeset 7628 in josm


Ignore:
Timestamp:
2014-10-17T00:45:28+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #5934 - error handling missing, when nominatim server returns garbage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r7082 r7628  
    3131import javax.swing.JButton;
    3232import javax.swing.JLabel;
     33import javax.swing.JOptionPane;
    3334import javax.swing.JPanel;
    3435import javax.swing.JScrollPane;
     
    5051import org.openstreetmap.josm.data.Bounds;
    5152import org.openstreetmap.josm.gui.ExceptionDialogUtil;
     53import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    5254import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     55import org.openstreetmap.josm.gui.util.GuiHelper;
    5356import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    5457import org.openstreetmap.josm.gui.widgets.JosmComboBox;
     
    6164import org.xml.sax.InputSource;
    6265import org.xml.sax.SAXException;
     66import org.xml.sax.SAXParseException;
    6367import org.xml.sax.helpers.DefaultHandler;
    6468
     
    379383                    this.data = parser.getResult();
    380384                }
    381             } catch(Exception e) {
    382                 if (canceled)
    383                     // ignore exception
    384                     return;
    385                 OsmTransferException ex = new OsmTransferException(e);
    386                 ex.setUrl(urlString);
    387                 lastException = ex;
     385            } catch (SAXParseException e) {
     386                if (!canceled) {
     387                    // Nominatim sometimes returns garbage, see #5934, #10643
     388                    Main.warn(tr("Error occured with query ''{0}'': ''{1}''", urlString, e.getMessage()));
     389                    GuiHelper.runInEDTAndWait(new Runnable() {
     390                        @Override
     391                        public void run() {
     392                            HelpAwareOptionPane.showOptionDialog(
     393                                    Main.parent,
     394                                    tr("Name server returned invalid data. Please try again."),
     395                                    tr("Bad response"),
     396                                    JOptionPane.WARNING_MESSAGE, null
     397                            );
     398                        }
     399                    });
     400                }
     401            } catch (Exception e) {
     402                if (!canceled) {
     403                    OsmTransferException ex = new OsmTransferException(e);
     404                    ex.setUrl(urlString);
     405                    lastException = ex;
     406                }
    388407            }
    389408        }
Note: See TracChangeset for help on using the changeset viewer.