Skip to content

Commit d6615c6

Browse files
committed
Collapse exceptions and assigned error Message on RepositoryErrorBundle class.
1 parent fcdcedf commit d6615c6

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

data/src/main/java/com/fernandocejas/android10/sample/data/cache/FileManager.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import android.content.SharedPreferences;
2020
import java.io.BufferedReader;
2121
import java.io.File;
22-
import java.io.FileNotFoundException;
2322
import java.io.FileReader;
2423
import java.io.FileWriter;
2524
import java.io.IOException;
@@ -48,12 +47,8 @@ public void writeToFile(File file, String fileContent) {
4847
FileWriter writer = new FileWriter(file);
4948
writer.write(fileContent);
5049
writer.close();
51-
} catch (FileNotFoundException e) {
52-
e.printStackTrace();
5350
} catch (IOException e) {
5451
e.printStackTrace();
55-
} finally {
56-
5752
}
5853
}
5954
}
@@ -78,8 +73,6 @@ public String readFileContent(File file) {
7873
}
7974
bufferedReader.close();
8075
fileReader.close();
81-
} catch (FileNotFoundException e) {
82-
e.printStackTrace();
8376
} catch (IOException e) {
8477
e.printStackTrace();
8578
}
@@ -105,12 +98,14 @@ public boolean exists(File file) {
10598
*
10699
* @param directory The directory which its content will be deleted.
107100
*/
108-
public void clearDirectory(File directory) {
101+
public boolean clearDirectory(File directory) {
102+
boolean result = false;
109103
if (directory.exists()) {
110104
for (File file : directory.listFiles()) {
111-
file.delete();
105+
result = file.delete();
112106
}
113107
}
108+
return result;
114109
}
115110

116111
/**

data/src/main/java/com/fernandocejas/android10/sample/data/exception/RepositoryErrorBundle.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.fernandocejas.android10.sample.data.exception;
1717

1818
import com.fernandocejas.android10.sample.domain.exception.ErrorBundle;
19+
import com.fernandocejas.frodo.core.strings.Strings;
1920

2021
/**
2122
* Wrapper around Exceptions used to manage errors in the repository.
@@ -35,9 +36,9 @@ public Exception getException() {
3536

3637
@Override
3738
public String getErrorMessage() {
38-
String message = "";
39+
String message = Strings.EMPTY;
3940
if (this.exception != null) {
40-
this.exception.getMessage();
41+
message = this.exception.getMessage();
4142
}
4243
return message;
4344
}

0 commit comments

Comments
 (0)