diff --git a/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java b/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java index eafcaac0650..2aec87957c9 100644 --- a/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java +++ b/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java @@ -9,6 +9,7 @@ import java.net.HttpURLConnection; import java.net.SocketException; import java.net.UnknownHostException; +import java.nio.file.FileSystemException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -143,6 +144,19 @@ public static void explainNestedIOException(OsmTransferException e) { ); } + /** + * Explains a {@link IOException} + * + * @param e the exception + */ + private static void explainIOException(Exception e) { + if (e instanceof FileSystemException && e.getMessage().contains("The device is not ready")) { + showErrorDialog(ExceptionUtil.explainException(e), tr("File System Exception"), null); + } else { + explainGeneric(e); + } + } + /** * Explains a {@link IllegalDataException} which has caused an {@link OsmTransferException}. * This is most likely happening when JOSM tries to load data in an unsupported format. @@ -492,6 +506,11 @@ public static void explainException(Exception e) { explainOsmTransferException((OsmTransferException) e); return; } + FileSystemException fileSystemException = ExceptionUtil.getNestedException(e, FileSystemException.class); + if (fileSystemException != null) { + explainIOException(fileSystemException); + return; + } explainGeneric(e); } } diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java b/src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java index eb9edaee527..5a7a8cf7a35 100644 --- a/src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java +++ b/src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -90,7 +91,14 @@ protected void realRun() throws IOException { progressMonitor.worked(1); ImageEntry e = new ImageEntry(f); - e.extractExif(); + try { + e.extractExif(); + } catch (UncheckedIOException uncheckedIOException) { + // We want to throw the actual IOException that is wrapped, not the unchecked IO exception. + // See #23866 + Logging.trace(uncheckedIOException); + throw uncheckedIOException.getCause(); + } File parentFile = f.getParentFile(); entries.computeIfAbsent(parentFile != null ? parentFile.getName() : "", x -> new ArrayList<>()).add(e); }