Ignore:
Timestamp:
2020-11-22T22:54:01+01:00 (3 years ago)
Author:
Don-vip
Message:

fix #20131 - remote control: report errors in case of OSM API error (load_and_zoom) or no valid identifier (load_object)

File:
1 edited

Legend:

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

    r13927 r17330  
    44import java.net.URL;
    55import java.util.List;
     6import java.util.Objects;
    67import java.util.concurrent.Future;
     8import java.util.stream.Collectors;
    79
    810import org.openstreetmap.josm.data.Bounds;
    911import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1012import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     13import org.openstreetmap.josm.tools.ExceptionUtil;
    1114
    1215/**
     
    116119
    117120    /**
     121     * Replies the error messages of the task. Empty list, if no error messages are available.
     122     *
     123     * @return the list of error messages
     124     * @since 17330
     125     */
     126    default List<String> getErrorMessages() {
     127        return getErrorObjects().stream().map(o -> {
     128            if (o instanceof String) {
     129                return (String) o;
     130            } else if (o instanceof Exception) {
     131                return ExceptionUtil.explainException((Exception) o).replace("<html>", "").replace("</html>", "");
     132            } else {
     133                return (String) null;
     134            }
     135        }).filter(Objects::nonNull).collect(Collectors.toList());
     136    }
     137
     138    /**
    118139     * Cancels the asynchronous download task.
    119140     *
Note: See TracChangeset for help on using the changeset viewer.