summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/android/configStore
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-09 09:37:49 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-09 09:37:49 -0600
commitdaacc06a0dcf4e8de371b9e177627ecd82e0ba17 (patch)
treedc476c95ee42bc9e019c1cccc93f295f6e3179af /app/src/main/java/com/wireguard/android/configStore
parenta1d955ef6264498c6c27569660152dbda7f60392 (diff)
global: Clean up error logging
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/configStore')
-rw-r--r--app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java7
1 files changed, 5 insertions, 2 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 dd2b434f..2b2e405b 100644
--- a/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
+++ b/app/src/main/java/com/wireguard/android/configStore/FileConfigStore.java
@@ -8,6 +8,7 @@ import com.wireguard.config.Config;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -31,6 +32,7 @@ public final class FileConfigStore implements ConfigStore {
@Override
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";
@@ -44,6 +46,7 @@ public final class FileConfigStore implements ConfigStore {
@Override
public void delete(final String name) throws IOException {
+ Log.d(TAG, "Deleting configuration for tunnel " + name);
final File file = fileFor(name);
if (!file.delete())
throw new IOException("Cannot delete configuration file " + file.getName());
@@ -70,11 +73,11 @@ public final class FileConfigStore implements ConfigStore {
@Override
public Config save(final String name, final Config config) throws IOException {
- Log.d(TAG, "Requested save config for tunnel " + name);
+ 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 IllegalStateException(message);
+ throw new FileNotFoundException(message);
}
try (FileOutputStream stream = new FileOutputStream(file, false)) {
stream.write(config.toString().getBytes(StandardCharsets.UTF_8));