mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 09:18:49 +00:00
Pretty-print missing recipientId crashes.
This commit is contained in:
parent
5e1bef26ed
commit
af96d11188
@ -270,7 +270,7 @@ public class RecipientDatabase extends Database {
|
||||
if (cursor != null && cursor.moveToNext()) {
|
||||
return getRecipientSettings(cursor);
|
||||
} else {
|
||||
throw new AssertionError("Couldn't find recipient! id: " + id.serialize());
|
||||
throw new MissingRecipientError(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -879,4 +879,9 @@ public class RecipientDatabase extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
public static class MissingRecipientError extends AssertionError {
|
||||
public MissingRecipientError(@Nullable RecipientId id) {
|
||||
super("Failed to find recipient with ID: " + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.MissingRecipientError;
|
||||
import org.thoughtcrime.securesms.util.LRUCache;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
|
||||
@ -44,7 +45,16 @@ public final class LiveRecipientCache {
|
||||
final LiveRecipient newLive = new LiveRecipient(context, new MutableLiveData<>(), new Recipient(id));
|
||||
|
||||
recipients.put(id, newLive);
|
||||
SignalExecutors.BOUNDED.execute(newLive::resolve);
|
||||
|
||||
MissingRecipientError prettyStackTraceError = new MissingRecipientError(newLive.getId());
|
||||
|
||||
SignalExecutors.BOUNDED.execute(() -> {
|
||||
try {
|
||||
newLive.resolve();
|
||||
} catch (MissingRecipientError e) {
|
||||
throw prettyStackTraceError;
|
||||
}
|
||||
});
|
||||
|
||||
live = newLive;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user