/
ErrorChecker.java
57 lines (44 loc) · 1.11 KB
/
ErrorChecker.java
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.iraycd.testcouchdblite.utils;
import android.content.Context;
import android.widget.Toast;
import com.couchbase.lite.Database;
import com.couchbase.lite.util.Log;
import com.iraycd.testcouchdblite.R;
/**
* Utility class for dealing with errors end exceptions.
*
* @author Nomad
*
*/
public class ErrorChecker {
public static final String TAG = "Coucher";
/**
* Check if db was created
* @return
*/
public static boolean checkDb(Context ctx, Database database){
if(database == null){
showError( ctx, R.string.err_no_db_set ) ;
return false;
}
return true;
}
/**
* Display err message
* @param errId
*/
public static void showError(Context ctx, int errId){
Toast.makeText(ctx, ctx.getResources().getString(errId), Toast.LENGTH_LONG)
.show();
}
/**
*
* @param ctx
* @param errId
* @param e
*/
public static void ShowException (Context ctx, int errId, Exception e){
showError( ctx, errId );
Log.e (TAG, e.getMessage(), e);
}
}