Skip to content

Commit 629e34f

Browse files
committed
Fix #23971: Give a nicer error message when a server is down
Signed-off-by: Taylor Smock <[email protected]>
1 parent 817b633 commit 629e34f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
3939
import org.openstreetmap.josm.gui.util.GuiHelper;
4040
import org.openstreetmap.josm.io.IllegalDataException;
41+
import org.openstreetmap.josm.io.OsmApiException;
4142
import org.openstreetmap.josm.io.OsmTransferException;
4243
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
4344
import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
@@ -198,9 +199,14 @@ private static void mergeDataSets(final DataSet original, final List<ForkJoinTas
198199
original.mergeFrom(ds.join());
199200
} catch (RuntimeException e) {
200201
final String notificationMessage;
201-
final var cause = e.getCause();
202-
if (cause instanceof IllegalDataException illegalDataException) {
203-
notificationMessage = ExceptionUtil.explainException(illegalDataException);
202+
Throwable cause = e.getCause();
203+
if (cause != null) {
204+
while (cause.getCause() != null && RuntimeException.class.equals(cause.getClass())) {
205+
cause = cause.getCause();
206+
}
207+
}
208+
if (cause instanceof IllegalDataException) {
209+
notificationMessage = ExceptionUtil.explainException((Exception) cause);
204210
Logging.trace(e);
205211
final var notification = new Notification();
206212
GuiHelper.runInEDT(() -> notification.setContent(notificationMessage));

0 commit comments

Comments
 (0)