summaryrefslogtreecommitdiffhomepage
path: root/app/src
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-09 23:57:15 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-09 23:57:15 -0600
commit5ce7eba2bf8b1b879581d32c327bdec6cd251718 (patch)
treeda9bcdc7a688dabb7ab749462658144fd72ecc2c /app/src
parentdfa4a2eb9d15e609cdd22fd1720f49ebbecfdbe6 (diff)
FileConfigStore: Simplify error handling
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
index 2b2e405b..68dfb485 100644
--- a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
+++ b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
@@ -34,10 +34,8 @@ public final class FileConfigStore implements ConfigStore {
public Config create(final String name, final Config config) throws IOException {
Log.d(TAG, "Creating configuration for tunnel " + name);
final File file = fileFor(name);
- if (!file.createNewFile()) {
- final String message = "Configuration file " + file.getName() + " already exists";
- throw new IllegalStateException(message);
- }
+ if (!file.createNewFile())
+ throw new IOException("Configuration file " + file.getName() + " already exists");
try (FileOutputStream stream = new FileOutputStream(file, false)) {
stream.write(config.toString().getBytes(StandardCharsets.UTF_8));
}
@@ -75,10 +73,8 @@ public final class FileConfigStore implements ConfigStore {
public Config save(final String name, final Config config) throws IOException {
Log.d(TAG, "Saving configuration for tunnel " + name);
final File file = fileFor(name);
- if (!file.isFile()) {
- final String message = "Configuration file " + file.getName() + " not found";
- throw new FileNotFoundException(message);
- }
+ if (!file.isFile())
+ throw new FileNotFoundException("Configuration file " + file.getName() + " not found");
try (FileOutputStream stream = new FileOutputStream(file, false)) {
stream.write(config.toString().getBytes(StandardCharsets.UTF_8));
}