From d205eda7f358cdc7966ddae58db4a3ad2c4db928 Mon Sep 17 00:00:00 2001 From: Robert Greene Date: Fri, 12 Dec 2003 04:25:24 +0000 Subject: [PATCH] Better error handling of invalid disks (or non-disks). --- .../ui/swt/SwtAppleCommander.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/com/webcodepro/applecommander/ui/swt/SwtAppleCommander.java b/src/com/webcodepro/applecommander/ui/swt/SwtAppleCommander.java index 653f53d..45f8a4e 100644 --- a/src/com/webcodepro/applecommander/ui/swt/SwtAppleCommander.java +++ b/src/com/webcodepro/applecommander/ui/swt/SwtAppleCommander.java @@ -25,8 +25,6 @@ import com.webcodepro.applecommander.storage.Disk.FilenameFilter; import com.webcodepro.applecommander.ui.AppleCommander; import com.webcodepro.applecommander.ui.UserPreferences; -import java.io.IOException; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; @@ -169,22 +167,31 @@ public class SwtAppleCommander implements Listener { DiskWindow window = new DiskWindow(shell, formattedDisks, imageManager); window.open(); } else { - Shell finalShell = shell; - MessageBox box = new MessageBox(finalShell, SWT.ICON_ERROR | SWT.OK); - box.setText("Unrecognized Disk Format"); - box.setMessage( - "Unable to load '" + fullpath + "'.\n\n" - + "AppleCommander did not recognize the format\n" - + "of that disk. Either this is a new format\n" - + "or a protected disk.\n\n" - + "Sorry!"); - box.open(); + showUnrecognizedDiskFormatMessage(fullpath); } - } catch (IOException ignored) { + } catch (Exception ignored) { + showUnrecognizedDiskFormatMessage(fullpath); } } } + /** + * Displays the unrecognized disk format message. + * @param fullpath + */ + private void showUnrecognizedDiskFormatMessage(String fullpath) { + Shell finalShell = shell; + MessageBox box = new MessageBox(finalShell, SWT.ICON_ERROR | SWT.OK); + box.setText("Unrecognized Disk Format"); + box.setMessage( + "Unable to load '" + fullpath + "'.\n\n" + + "AppleCommander did not recognize the format\n" + + "of the disk. Either this is a new format\n" + + "or a protected disk.\n\n" + + "Sorry!"); + box.open(); + } + /** * Create a disk image. */