Catch exceptions

pull/147/head
M66B 6 years ago
parent 0aed1c3957
commit acf7ab2107

@ -306,7 +306,8 @@ public class ServiceSynchronize extends LifecycleService {
super.onStartCommand(intent, flags, startId);
if (action != null) {
if (action != null)
try {
final String[] parts = action.split(":");
switch (parts[0]) {
case "why":
@ -339,7 +340,11 @@ public class ServiceSynchronize extends LifecycleService {
executor.submit(new Runnable() {
@Override
public void run() {
try {
DB.getInstance(ServiceSynchronize.this).message().ignoreAll();
} catch (Throwable ex) {
Log.e(ex);
}
}
});
break;
@ -351,13 +356,13 @@ public class ServiceSynchronize extends LifecycleService {
executor.submit(new Runnable() {
@Override
public void run() {
long id = Long.parseLong(parts[1]);
DB db = DB.getInstance(ServiceSynchronize.this);
try {
db.beginTransaction();
long id = Long.parseLong(parts[1]);
EntityMessage message = db.message().getMessage(id);
switch (parts[0]) {
case "seen":
EntityOperation.queue(db, message, EntityOperation.SEEN, true);
@ -386,6 +391,8 @@ public class ServiceSynchronize extends LifecycleService {
}
db.setTransactionSuccessful();
} catch (Throwable ex) {
Log.e(ex);
} finally {
db.endTransaction();
}
@ -396,6 +403,8 @@ public class ServiceSynchronize extends LifecycleService {
default:
Log.w("Unknown action: " + action);
}
} catch (Throwable ex) {
Log.e(ex);
}
return START_STICKY;

Loading…
Cancel
Save