Browse Source

Throw exceptions is we fail to delete config file based things.

Change-Id: I4fa54ebe8f4ff93c8fc33504af66338eda01d0b8
Depends-On: I752f5bebe42514f1dc21e1b77e1ee5a649f324f5
Depends-On: I9463e66dc39881bcc69b64b8900df1010683b0bc
Depends-On: I752f5bebe42514f1dc21e1b77e1ee5a649f324f5
Reviewed-on: http://gerrit.dmdirc.com/3503
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
pull/1/head
Greg Holmes 10 years ago
parent
commit
6c730e6ff2

+ 4
- 1
src/com/dmdirc/actions/wrappers/Profile.java View File

27
 
27
 
28
 import com.google.common.base.Preconditions;
28
 import com.google.common.base.Preconditions;
29
 
29
 
30
+import java.io.IOException;
30
 import java.util.ArrayList;
31
 import java.util.ArrayList;
31
 import java.util.Arrays;
32
 import java.util.Arrays;
32
 import java.util.List;
33
 import java.util.List;
189
 
190
 
190
     /**
191
     /**
191
      * Deletes the profile.
192
      * Deletes the profile.
193
+     *
194
+     * @throws IOException if unable to delete the profile
192
      */
195
      */
193
-    public void delete() {
196
+    public void delete() throws IOException {
194
         if (configProvider == null) {
197
         if (configProvider == null) {
195
             return;
198
             return;
196
         }
199
         }

+ 1
- 1
src/com/dmdirc/config/ConfigFileBackedConfigProvider.java View File

479
     }
479
     }
480
 
480
 
481
     @Override
481
     @Override
482
-    public synchronized void delete() {
482
+    public synchronized void delete() throws IOException {
483
         if (file != null) {
483
         if (file != null) {
484
             file.delete();
484
             file.delete();
485
         }
485
         }

+ 3
- 1
src/com/dmdirc/interfaces/config/ConfigProvider.java View File

43
 
43
 
44
     /**
44
     /**
45
      * Deletes this identity from disk.
45
      * Deletes this identity from disk.
46
+     *
47
+     * @throws IOException if the file fails to delete
46
      */
48
      */
47
-    void delete();
49
+    void delete() throws IOException;
48
 
50
 
49
     /**
51
     /**
50
      * Returns the set of domains available in this identity.
52
      * Returns the set of domains available in this identity.

+ 3
- 3
test/com/dmdirc/actions/wrappers/ProfileTest.java View File

21
  */
21
  */
22
 package com.dmdirc.actions.wrappers;
22
 package com.dmdirc.actions.wrappers;
23
 
23
 
24
-import com.dmdirc.actions.wrappers.Profile;
25
 import com.dmdirc.interfaces.config.ConfigProvider;
24
 import com.dmdirc.interfaces.config.ConfigProvider;
26
 import com.dmdirc.interfaces.config.IdentityFactory;
25
 import com.dmdirc.interfaces.config.IdentityFactory;
27
 
26
 
27
+import java.io.IOException;
28
 import java.util.ArrayList;
28
 import java.util.ArrayList;
29
 import java.util.Arrays;
29
 import java.util.Arrays;
30
 import java.util.List;
30
 import java.util.List;
224
      * Test of delete method, of class Profile.
224
      * Test of delete method, of class Profile.
225
      */
225
      */
226
     @Test
226
     @Test
227
-    public void testDelete() {
227
+    public void testDelete() throws IOException {
228
         final List<String> nicknames = new ArrayList<>();
228
         final List<String> nicknames = new ArrayList<>();
229
         nicknames.add("nickname1");
229
         nicknames.add("nickname1");
230
         nicknames.add("nickname2");
230
         nicknames.add("nickname2");
244
      * Test of delete method, of class Profile.
244
      * Test of delete method, of class Profile.
245
      */
245
      */
246
     @Test
246
     @Test
247
-    public void testDeleteNullIdentity() {
247
+    public void testDeleteNullIdentity() throws IOException {
248
         Profile instance = new Profile("New Profile", null);
248
         Profile instance = new Profile("New Profile", null);
249
         instance.delete();
249
         instance.delete();
250
     }
250
     }

Loading…
Cancel
Save