diff options
| author | Ben Culkin <scorpress@gmail.com> | 2020-10-06 19:26:52 -0400 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2020-10-06 19:26:52 -0400 |
| commit | a7a87f682a039d4761112f1dedb9351f3d7a2bbf (patch) | |
| tree | 14688fcc9f8f0d8dee718e213ba5725a7ddc2db1 /base/src/main/java/bjc/utils/gui/SimpleFileChooser.java | |
| parent | 9dd6cd76e45335f5d303456a648c3eca9c5bf930 (diff) | |
Rename exceptions to not use Exception
This renames several of the stock exceptions to remove 'Exception' from
their name. This is something that I don't recall where I picked it up
from, but the idea is that the fact that it is an exception is generally
syntactically obvious. Therefore, you can instead give your exceptions
names which directly state what it wrong, as well as strongly implying
what you can do to fix it.
For instance, if you get a DirectionInvalid, it is apparent what the
issue is (it is less apparent why it is invalid, but that is another
issue, and a discussion for another time)
Diffstat (limited to 'base/src/main/java/bjc/utils/gui/SimpleFileChooser.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/gui/SimpleFileChooser.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java b/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java index 7be9f84..d6ae97b 100644 --- a/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java +++ b/base/src/main/java/bjc/utils/gui/SimpleFileChooser.java @@ -5,7 +5,7 @@ import java.io.File; import javax.swing.JFileChooser; -import bjc.utils.exceptions.FileNotChosenException; +import bjc.utils.exceptions.NoFileChosen; /** * Utility class for easily prompting user for files. @@ -30,7 +30,7 @@ public class SimpleFileChooser { maybeDoOpenFile(parent, files); success = true; - } catch (final FileNotChosenException fncx) { + } catch (final NoFileChosen fncx) { // We don't care about specifics SimpleDialogs.showError(parent, "I/O Error", "Please pick a file to open"); @@ -54,7 +54,7 @@ public class SimpleFileChooser { maybeDoSaveFile(parent, files); return files.getSelectedFile(); - } catch (final FileNotChosenException fncex) { + } catch (final NoFileChosen fncex) { // We don't care about specifics SimpleDialogs.showError(parent, "I/O Error", "Please pick a file to save to"); @@ -135,7 +135,7 @@ public class SimpleFileChooser { } private static void maybeDoOpenFile(final Component parent, final JFileChooser files) - throws FileNotChosenException { + throws NoFileChosen { if (parent == null) throw new NullPointerException("Parent must not be null"); else if (files == null) @@ -144,11 +144,11 @@ public class SimpleFileChooser { final int result = files.showSaveDialog(parent); if (result != JFileChooser.APPROVE_OPTION) - throw new FileNotChosenException(); + throw new NoFileChosen(); } private static void maybeDoSaveFile(final Component parent, final JFileChooser files) - throws FileNotChosenException { + throws NoFileChosen { if (parent == null) throw new NullPointerException("Parent must not be null"); else if (files == null) @@ -157,7 +157,7 @@ public class SimpleFileChooser { final int result = files.showSaveDialog(parent); if (result != JFileChooser.APPROVE_OPTION) - throw new FileNotChosenException(); + throw new NoFileChosen(); } /** @@ -178,7 +178,7 @@ public class SimpleFileChooser { try { maybeDoOpenFile(parent, files); - } catch (final FileNotChosenException fncex) { + } catch (final NoFileChosen fncex) { // We don't care about specifics } @@ -203,7 +203,7 @@ public class SimpleFileChooser { try { maybeDoSaveFile(parent, files); - } catch (final FileNotChosenException fncex) { + } catch (final NoFileChosen fncex) { // We don't care about specifics } |
