mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-10 14:18:33 +00:00
Downgrade some job exceptions.
Runtime exceptions were being thrown where it'd be safer to either ignore it or throw a checked, failing exception.
This commit is contained in:
parent
bdf93af3db
commit
7ae5159194
@ -94,7 +94,7 @@ public class AttachmentUploadJob extends BaseJob {
|
||||
DatabaseAttachment databaseAttachment = database.getAttachment(attachmentId);
|
||||
|
||||
if (databaseAttachment == null) {
|
||||
throw new IllegalStateException("Cannot find the specified attachment.");
|
||||
throw new InvalidAttachmentException("Cannot find the specified attachment.");
|
||||
}
|
||||
|
||||
MediaConstraints mediaConstraints = MediaConstraints.getPushMediaConstraints();
|
||||
@ -132,7 +132,9 @@ public class AttachmentUploadJob extends BaseJob {
|
||||
* The {@link PartProgressEvent} of this task will fit in the remaining
|
||||
* 1 - progressStartPoint.
|
||||
*/
|
||||
private SignalServiceAttachment getAttachmentFor(Attachment attachment, @Nullable NotificationController notification, double progressStartPoint) {
|
||||
private @NonNull SignalServiceAttachment getAttachmentFor(Attachment attachment, @Nullable NotificationController notification, double progressStartPoint)
|
||||
throws InvalidAttachmentException
|
||||
{
|
||||
try {
|
||||
if (attachment.getDataUri() == null || attachment.getSize() == 0) throw new IOException("Assertion failed, outgoing attachment has no data!");
|
||||
InputStream is = PartAuthority.getAttachmentStream(context, attachment.getDataUri());
|
||||
@ -154,9 +156,8 @@ public class AttachmentUploadJob extends BaseJob {
|
||||
})
|
||||
.build();
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, "Couldn't open attachment", ioe);
|
||||
throw new InvalidAttachmentException(ioe);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Attachment scaleAndStripExif(@NonNull AttachmentDatabase attachmentDatabase,
|
||||
@ -178,6 +179,16 @@ public class AttachmentUploadJob extends BaseJob {
|
||||
progressListener);
|
||||
}
|
||||
|
||||
private class InvalidAttachmentException extends Exception {
|
||||
InvalidAttachmentException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
InvalidAttachmentException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Factory implements Job.Factory<AttachmentUploadJob> {
|
||||
@Override
|
||||
public @NonNull AttachmentUploadJob create(@NonNull Parameters parameters, @NonNull org.thoughtcrime.securesms.jobmanager.Data data) {
|
||||
|
@ -77,7 +77,8 @@ public class TypingSendJob extends BaseJob {
|
||||
Recipient recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId);
|
||||
|
||||
if (recipient == null) {
|
||||
throw new IllegalStateException("Tried to send a typing indicator to a non-existent thread.");
|
||||
Log.w(TAG, "Tried to send a typing indicator to a non-existent thread.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Recipient> recipients = Collections.singletonList(recipient);
|
||||
|
Loading…
x
Reference in New Issue
Block a user