Changeset 8782 in josm


Ignore:
Timestamp:
2015-09-22T19:45:32+02:00 (9 years ago)
Author:
simon04
Message:

see #11428 - Extract Overpass request errors

Those error messages are nicely displayed in the error dialog.

This is a workaround for https://github.com/drolbr/Overpass-API/issues/94

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OverpassDownloadReader.java

    r8764 r8782  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.io;
     3
     4import java.io.InputStream;
    35
    46import org.openstreetmap.josm.data.Bounds;
     
    8082
    8183    @Override
     84    protected InputStream getInputStreamRaw(String urlStr, ProgressMonitor progressMonitor, String reason,
     85                                            boolean uncompressAccordingToContentDisposition) throws OsmTransferException {
     86        try {
     87            return super.getInputStreamRaw(urlStr, progressMonitor, reason, uncompressAccordingToContentDisposition);
     88        } catch (OsmApiException ex) {
     89            final String errorIndicator = "Error</strong>: ";
     90            if (ex.getMessage() != null && ex.getMessage().contains(errorIndicator)) {
     91                final String errorPlusRest = ex.getMessage().split(errorIndicator)[1];
     92                if (errorPlusRest != null) {
     93                    final String error = errorPlusRest.split("</")[0];
     94                    ex.setErrorHeader(error);
     95                }
     96            }
     97            throw ex;
     98        }
     99    }
     100
     101    @Override
    82102    public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
    83103
Note: See TracChangeset for help on using the changeset viewer.