Changeset 9184 in josm for trunk


Ignore:
Timestamp:
2015-12-28T00:02:30+01:00 (8 years ago)
Author:
simon04
Message:

see #12231 - fix MultiFetchServerObjectReaderTest#multiGetWithNonExistingNode

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

Legend:

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

    r9174 r9184  
    148148                if (activeConnection.getResponseCode() != HttpURLConnection.HTTP_OK) {
    149149                    String errorHeader = activeConnection.getHeaderField("Error");
    150                     final String errorBody = activeConnection.fetchContent();
     150                    String errorBody;
     151                    try {
     152                        errorBody = activeConnection.fetchContent();
     153                    } catch (Exception e) {
     154                        errorBody = tr("Reading error text failed.");
     155                    }
    151156                    throw new OsmApiException(activeConnection.getResponseCode(), errorHeader, errorBody, url.toString());
    152157                }
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r9182 r9184  
    104104            try {
    105105                connection.connect();
    106                 if (reasonForRequest != null && "".equalsIgnoreCase(reasonForRequest)) {
    107                     Main.info("{0} {1} ({2}) -> {3}", requestMethod, url, reasonForRequest, connection.getResponseCode());
    108                 } else {
    109                     Main.info("{0} {1} -> {2}", requestMethod, url, connection.getResponseCode());
    110                 }
     106                final boolean hasReason = reasonForRequest != null && "".equalsIgnoreCase(reasonForRequest);
     107                Main.info("{0} {1}{2} -> {3}{4}",
     108                        requestMethod, url, hasReason ? " (" + reasonForRequest + ")" : "",
     109                        connection.getResponseCode(),
     110                        connection.getContentLengthLong() > 0 ? " (" + connection.getContentLengthLong() / 1024 + "KB)" : ""
     111                );
    111112                if (Main.isDebugEnabled()) {
    112113                    Main.debug("RESPONSE: " + connection.getHeaderFields());
    113114                }
    114115            } catch (IOException e) {
     116                Main.info("{0} {1} -> !!!", requestMethod, url);
    115117                Main.warn(e);
    116118                //noinspection ThrowableResultOfMethodCallIgnored
Note: See TracChangeset for help on using the changeset viewer.