Ignore:
Timestamp:
2023-08-22T17:26:18+02:00 (9 months ago)
Author:
taylor.smock
Message:

Fix #23134: Cancelling a json download will cause an exception dialog

We extract the underlying IOException from the JsonException into an
IllegalDataException which can be parsed by calling methods and properly handled.

File:
1 edited

Legend:

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

    r18723 r18816  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
    67import java.io.InputStream;
    7 import java.net.SocketException;
    88import java.util.Collection;
    99import java.util.Map.Entry;
     
    3333/**
    3434 * Parser for the Osm API (JSON output). Read from an input stream and construct a dataset out of it.
    35  *
     35 * <p>
    3636 * For each json element, there is a dedicated method.
    3737 * @since 14086
     
    190190            throw new IllegalDataException(exception);
    191191        } catch (JsonException exception) {
    192             if (exception.getCause() instanceof SocketException) {
    193                 SocketException soe = (SocketException) exception.getCause();
     192            if (exception.getCause() instanceof IOException) {
     193                IOException soe = (IOException) exception.getCause();
    194194                soe.addSuppressed(exception); // Add the caught exception as a suppressed exception
    195195                throw new IllegalDataException(soe); // NOPMD -- PreserveStackTrace should be fixed with PMD 7
Note: See TracChangeset for help on using the changeset viewer.