Skip to content

Commit

Permalink
Fix #23971: Give a nicer error message when a server is down
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Oct 21, 2024
1 parent 817b633 commit 629e34f
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
import org.openstreetmap.josm.gui.util.GuiHelper;
import org.openstreetmap.josm.io.IllegalDataException;
import org.openstreetmap.josm.io.OsmApiException;
import org.openstreetmap.josm.io.OsmTransferException;
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
Expand Down Expand Up @@ -198,9 +199,14 @@ private static void mergeDataSets(final DataSet original, final List<ForkJoinTas
original.mergeFrom(ds.join());
} catch (RuntimeException e) {
final String notificationMessage;
final var cause = e.getCause();
if (cause instanceof IllegalDataException illegalDataException) {
notificationMessage = ExceptionUtil.explainException(illegalDataException);
Throwable cause = e.getCause();
if (cause != null) {
while (cause.getCause() != null && RuntimeException.class.equals(cause.getClass())) {
cause = cause.getCause();
}
}
if (cause instanceof IllegalDataException) {
notificationMessage = ExceptionUtil.explainException((Exception) cause);
Logging.trace(e);
final var notification = new Notification();
GuiHelper.runInEDT(() -> notification.setContent(notificationMessage));
Expand Down

0 comments on commit 629e34f

Please sign in to comment.