-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorHandler.java
More file actions
33 lines (23 loc) · 1.03 KB
/
Copy pathErrorHandler.java
File metadata and controls
33 lines (23 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package util;
import android.content.Context;
import android.widget.Toast;
import org.json.JSONException;
import java.io.FileNotFoundException;
import java.io.IOException;
public class ErrorHandler {
public static void handleFileNotFoundError(Context context, Exception e) {
Toast.makeText(context, "File not found: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
public static void handleJsonParsingError(Context context, JSONException e) {
Toast.makeText(context, "JSON parsing error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
public static void handleIOException(Context context, IOException e) {
Toast.makeText(context, "Input/Output error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
public static void handleGenericError(Context context, Exception e) {
Toast.makeText(context, "An error occurred: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
public static void logError(Exception e) {
e.printStackTrace();
}
}