From bf3835d6a6bf96d1c9ea5c4a10aa5f926b994b1e Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Jun 2024 09:46:20 +0930 Subject: [PATCH] Simplify Exception handling in NewMessage --- .../conversation/newmessage/NewMessageViewModel.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/newmessage/NewMessageViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/newmessage/NewMessageViewModel.kt index a8a76db74f..a0c6ba50f8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/newmessage/NewMessageViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/newmessage/NewMessageViewModel.kt @@ -84,11 +84,12 @@ class NewMessageViewModel @Inject constructor( _state.update { it.copy(loading = false) } onPublicKey(onsNameOrPublicKey) } + } catch (e: TimeoutCancellationException) { + onError(e) } catch (e: CancellationException) { - if (e is TimeoutCancellationException) { - // Ignore JobCancellationException, which is called when we cancel the job. - onError(e) - } + // Ignore JobCancellationException, which is called when we cancel the job and + // is handled where the job is canceled. + // Can't reference JobCancellationException directly, it is internal. } catch (e: Exception) { onError(e) }