diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml index eea44a16..55bb1265 100644 --- a/app/detekt-baseline.xml +++ b/app/detekt-baseline.xml @@ -1,5 +1,6 @@ + CyclomaticComplexMethod:ChatScreen.kt$@Composable private fun ChatMessageListItem( chatMessage: ChatMessageUi, previousMessage: ChatMessageUi? = null, nextMessage: ChatMessageUi? = null, onProfileClick: (String) -> Unit, onNoteClick: (String) -> Unit, onUrlClick: (String) -> Unit, onHashtagClick: (String) -> Unit, onMediaClick: (String, String) -> Unit, ) CyclomaticComplexMethod:CreateAccountViewModel.kt$CreateAccountViewModel$private fun observeEvents() @@ -39,7 +40,6 @@ LongMethod:ExploreFeedScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun ExploreFeedScreen( state: ExploreFeedContract.UiState, onClose: () -> Unit, onPostClick: (String) -> Unit, onPostReplyClick: (String) -> Unit, onPostQuoteClick: (String) -> Unit, onProfileClick: (String) -> Unit, onHashtagClick: (String) -> Unit, onMediaClick: (String, String) -> Unit, onGoToWallet: () -> Unit, eventPublisher: (ExploreFeedContract.UiEvent) -> Unit, ) LongMethod:ExploreHomeScreen.kt$@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) @Composable fun ExploreHomeScreen( state: ExploreHomeContract.UiState, onHashtagClick: (String) -> Unit, onSearchClick: () -> Unit, onPrimaryDestinationChanged: (PrimalTopLevelDestination) -> Unit, onDrawerDestinationClick: (DrawerScreenDestination) -> Unit, eventPublisher: (UiEvent) -> Unit, ) LongMethod:FeedLazyColumn.kt$@ExperimentalMaterial3Api @ExperimentalFoundationApi @Composable fun FeedLazyColumn( pagingItems: LazyPagingItems<FeedPostUi>, contentPadding: PaddingValues, listState: LazyListState, zappingState: ZappingState, onPostClick: (String) -> Unit, onProfileClick: (String) -> Unit, onPostLikeClick: (FeedPostUi) -> Unit, onRepostClick: (FeedPostUi) -> Unit, onZapClick: (FeedPostUi, ULong?, String?) -> Unit, onPostReplyClick: (String) -> Unit, onPostQuoteClick: (FeedPostUi) -> Unit, onHashtagClick: (String) -> Unit, onMediaClick: (String, String) -> Unit, onGoToWallet: () -> Unit, onMuteClick: ((String) -> Unit)? = null, shouldShowLoadingState: Boolean = true, shouldShowNoContentState: Boolean = true, header: @Composable (LazyItemScope.() -> Unit)? = null, stickyHeader: @Composable (LazyItemScope.() -> Unit)? = null, ) - LongMethod:FeedNoteCard.kt$@Composable fun FeedNoteCard( data: FeedPostUi, modifier: Modifier = Modifier, shape: Shape = CardDefaults.shape, colors: CardColors = CardDefaults.cardColors(), cardPadding: PaddingValues = PaddingValues(all = 0.dp), fullWidthNote: Boolean = false, headerSingleLine: Boolean = true, fullWidthContent: Boolean = false, forceContentIndent: Boolean = false, drawLineAboveAvatar: Boolean = false, drawLineBelowAvatar: Boolean = false, expanded: Boolean = false, onPostClick: (String) -> Unit, onProfileClick: (String) -> Unit, onPostAction: ((FeedPostAction) -> Unit)? = null, onPostLongClickAction: ((FeedPostAction) -> Unit)? = null, onHashtagClick: (String) -> Unit, onMediaClick: (String, String) -> Unit, onMuteUserClick: () -> Unit, ) LongMethod:FeedRemoteMediator.kt$FeedRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState<Int, FeedPost>): MediatorResult LongMethod:FeedScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun FeedScreen( state: FeedContract.UiState, eventPublisher: (FeedContract.UiEvent) -> Unit, onFeedsClick: () -> Unit, onNewPostClick: (String?) -> Unit, onPostClick: (String) -> Unit, onPostReplyClick: (String) -> Unit, onProfileClick: (String) -> Unit, onHashtagClick: (String) -> Unit, onMediaClick: (String, String) -> Unit, onGoToWallet: () -> Unit, onPrimaryDestinationChanged: (PrimalTopLevelDestination) -> Unit, onDrawerDestinationClick: (DrawerScreenDestination) -> Unit, ) LongMethod:FeedsSettingsScreen.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun FeedsSettingsScreen( state: FeedsSettingsContract.UiState, eventPublisher: (FeedsSettingsContract.UiEvent) -> Unit, onClose: () -> Unit, ) @@ -151,21 +151,6 @@ ReturnCount:NotificationEvents.kt$fun ContentPrimalNotification.asNotificationPOOrNull(): NotificationData? ReturnCount:NotificationsRemoteMediator.kt$NotificationsRemoteMediator$override suspend fun load(loadType: LoadType, state: PagingState<Int, Notification>): MediatorResult ReturnCount:WalletTransactionsMediator.kt$WalletTransactionsMediator$override suspend fun load(loadType: LoadType, state: PagingState<Int, WalletTransaction>): MediatorResult - SwallowedException:CredentialsStore.kt$CredentialsStore$error: DecoderException - SwallowedException:CredentialsStore.kt$CredentialsStore$error: IllegalArgumentException - SwallowedException:EditProfileViewModel.kt$EditProfileViewModel$error: WssException - SwallowedException:NostrEvents.kt$error: IllegalArgumentException - SwallowedException:NostrNotary.kt$NostrNotary$error: IllegalArgumentException - SwallowedException:Parsers.kt$error: SerializationException - SwallowedException:PostRepository.kt$PostRepository$error: WssException - SwallowedException:PrimalProfileStatsAndScores.kt$error: IllegalArgumentException - SwallowedException:ProfileScreen.kt$error: ActivityNotFoundException - SwallowedException:RelayPool.kt$RelayPool$error: IllegalArgumentException - SwallowedException:SearchViewModel.kt$SearchViewModel$error: WssException - SwallowedException:UriHandlerExt.kt$error: ActivityNotFoundException - SwallowedException:ValidationUtils.kt$error: DecoderException - SwallowedException:ValidationUtils.kt$error: IllegalArgumentException - SwallowedException:WalletActivationScreen.kt$error: IOException ThrowingExceptionsWithoutMessageOrCause:ExploreFeedViewModel.kt$ExploreFeedViewModel$IllegalStateException() ThrowingExceptionsWithoutMessageOrCause:FeedViewModel.kt$FeedViewModel$IllegalStateException() ThrowingExceptionsWithoutMessageOrCause:NotificationsViewModel.kt$NotificationsViewModel$IllegalStateException() diff --git a/app/src/google/kotlin/net/primal/android/wallet/store/play/PlayBillingClient.kt b/app/src/google/kotlin/net/primal/android/wallet/store/play/PlayBillingClient.kt index c7efb024..d0a71a98 100644 --- a/app/src/google/kotlin/net/primal/android/wallet/store/play/PlayBillingClient.kt +++ b/app/src/google/kotlin/net/primal/android/wallet/store/play/PlayBillingClient.kt @@ -104,7 +104,7 @@ class PlayBillingClient @Inject constructor( } } } catch (error: TimeoutCancellationException) { - Timber.e(error) + Timber.w(error) false } } diff --git a/app/src/main/kotlin/net/primal/android/auth/create/CreateAccountViewModel.kt b/app/src/main/kotlin/net/primal/android/auth/create/CreateAccountViewModel.kt index 4528e418..2baf7a2b 100644 --- a/app/src/main/kotlin/net/primal/android/auth/create/CreateAccountViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/auth/create/CreateAccountViewModel.kt @@ -123,12 +123,15 @@ class CreateAccountViewModel @Inject constructor( currentStep = UiState.CreateAccountStep.ACCOUNT_CREATED, ) } - } catch (e: UnsuccessfulFileUpload) { - setState { copy(error = UiState.CreateError.FailedToUploadImage(e)) } - } catch (e: NostrPublishException) { - setState { copy(error = UiState.CreateError.FailedToCreateMetadata(e)) } - } catch (e: WssException) { - setState { copy(error = UiState.CreateError.FailedToCreateMetadata(e)) } + } catch (error: UnsuccessfulFileUpload) { + Timber.w(error) + setState { copy(error = UiState.CreateError.FailedToUploadImage(error)) } + } catch (error: NostrPublishException) { + Timber.w(error) + setState { copy(error = UiState.CreateError.FailedToCreateMetadata(error)) } + } catch (error: WssException) { + Timber.w(error) + setState { copy(error = UiState.CreateError.FailedToCreateMetadata(error)) } } finally { setState { copy(loading = false) } } @@ -158,8 +161,9 @@ class CreateAccountViewModel @Inject constructor( currentStep = UiState.CreateAccountStep.FOLLOW_RECOMMENDED_ACCOUNTS, ) } - } catch (e: IOException) { - setState { copy(error = UiState.CreateError.FailedToFetchRecommendedFollows(e)) } + } catch (error: IOException) { + Timber.w(error) + setState { copy(error = UiState.CreateError.FailedToFetchRecommendedFollows(error)) } } finally { setState { copy(loading = false) } } @@ -181,10 +185,10 @@ class CreateAccountViewModel @Inject constructor( } setEffect(SideEffect.AccountCreatedAndPersisted(pubkey = userId)) } catch (error: NostrPublishException) { - Timber.e(error) + Timber.w(error) setState { copy(error = UiState.CreateError.FailedToFollow(error)) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) setState { copy(error = UiState.CreateError.FailedToFollow(error)) } } finally { setState { copy(loading = false) } diff --git a/app/src/main/kotlin/net/primal/android/auth/login/LoginViewModel.kt b/app/src/main/kotlin/net/primal/android/auth/login/LoginViewModel.kt index db5284a5..331e382c 100644 --- a/app/src/main/kotlin/net/primal/android/auth/login/LoginViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/auth/login/LoginViewModel.kt @@ -81,7 +81,7 @@ class LoginViewModel @Inject constructor( val defaultFeed = withContext(dispatcherProvider.io()) { feedRepository.defaultFeed() } setEffect(SideEffect.LoginSuccess(feedDirective = defaultFeed?.directive ?: userId)) } catch (error: WssException) { - Timber.e(error) + Timber.w(error) setErrorState(error = UiState.LoginError.GenericError(error)) } finally { setState { copy(loading = false) } diff --git a/app/src/main/kotlin/net/primal/android/core/ext/UriHandlerExt.kt b/app/src/main/kotlin/net/primal/android/core/ext/UriHandlerExt.kt index d8665e5f..b63e3d8d 100644 --- a/app/src/main/kotlin/net/primal/android/core/ext/UriHandlerExt.kt +++ b/app/src/main/kotlin/net/primal/android/core/ext/UriHandlerExt.kt @@ -2,11 +2,13 @@ package net.primal.android.core.ext import android.content.ActivityNotFoundException import androidx.compose.ui.platform.UriHandler +import timber.log.Timber fun UriHandler.openUriSafely(uri: String) { try { openUri(uri) } catch (error: ActivityNotFoundException) { + Timber.w(error) runCatching { val scheme = if (uri.contains("@")) "mailto" else "https" openUri("$scheme://$uri") diff --git a/app/src/main/kotlin/net/primal/android/core/files/FileUploader.kt b/app/src/main/kotlin/net/primal/android/core/files/FileUploader.kt index 409817e2..2536a1b4 100644 --- a/app/src/main/kotlin/net/primal/android/core/files/FileUploader.kt +++ b/app/src/main/kotlin/net/primal/android/core/files/FileUploader.kt @@ -20,6 +20,7 @@ import net.primal.android.networking.primal.PrimalVerb import net.primal.android.networking.sockets.errors.WssException import net.primal.android.nostr.model.NostrEventKind import net.primal.android.nostr.notary.NostrNotary +import timber.log.Timber @Singleton class FileUploader @Inject constructor( @@ -48,10 +49,13 @@ class FileUploader @Inject constructor( ), ) } catch (error: WssException) { + Timber.w(error) throw UnsuccessfulFileUpload(cause = error) } catch (error: IOException) { + Timber.w(error) throw UnsuccessfulFileUpload(cause = error) } catch (error: UnknownHostException) { + Timber.w(error) throw UnsuccessfulFileUpload(cause = error) } diff --git a/app/src/main/kotlin/net/primal/android/core/serialization/json/NostrJson.kt b/app/src/main/kotlin/net/primal/android/core/serialization/json/NostrJson.kt index 94158ef3..e6c5fa25 100644 --- a/app/src/main/kotlin/net/primal/android/core/serialization/json/NostrJson.kt +++ b/app/src/main/kotlin/net/primal/android/core/serialization/json/NostrJson.kt @@ -32,7 +32,7 @@ inline fun Json.decodeFromStringOrNull(string: String?): T? { return try { decodeFromString(string) } catch (error: IllegalArgumentException) { - Timber.e(error) + Timber.w(error) null } } diff --git a/app/src/main/kotlin/net/primal/android/core/utils/UriUtils.kt b/app/src/main/kotlin/net/primal/android/core/utils/UriUtils.kt index b7e9ddb3..57bb2eb7 100644 --- a/app/src/main/kotlin/net/primal/android/core/utils/UriUtils.kt +++ b/app/src/main/kotlin/net/primal/android/core/utils/UriUtils.kt @@ -6,6 +6,7 @@ import com.linkedin.urls.detection.UrlDetectorOptions import java.net.MalformedURLException import java.net.URL import net.primal.android.nostr.ext.parseNostrUris +import timber.log.Timber fun String.parseUris(): List { val urlDetector = UrlDetector(this, UrlDetectorOptions.JSON) @@ -82,6 +83,7 @@ fun String?.detectMimeType(): String? { val ref = try { URL(this).file } catch (error: MalformedURLException) { + Timber.w(error) this } val extension = ref.substringAfterLast(".", "") diff --git a/app/src/main/kotlin/net/primal/android/core/utils/ValidationUtils.kt b/app/src/main/kotlin/net/primal/android/core/utils/ValidationUtils.kt index d060a0ac..d3612755 100644 --- a/app/src/main/kotlin/net/primal/android/core/utils/ValidationUtils.kt +++ b/app/src/main/kotlin/net/primal/android/core/utils/ValidationUtils.kt @@ -4,6 +4,7 @@ import net.primal.android.crypto.Bech32 import net.primal.android.crypto.hexToNpubHrp import net.primal.android.crypto.hexToNsecHrp import org.spongycastle.util.encoders.DecoderException +import timber.log.Timber fun String?.isValidNostrPrivateKey(): Boolean { if (this == null) return false @@ -14,6 +15,7 @@ fun String?.isValidNostrPrivateKey(): Boolean { try { this.hexToNsecHrp().isValidNsec() } catch (error: DecoderException) { + Timber.w(error) false } } @@ -28,6 +30,7 @@ fun String?.isValidNostrPublicKey(): Boolean { try { this.hexToNpubHrp().isValidNpub() } catch (error: DecoderException) { + Timber.w(error) false } } @@ -40,6 +43,7 @@ private fun String.isValidNsec(): Boolean { val decoded = Bech32.decodeBytes(this) decoded.first == "nsec" && decoded.second.size == 32 } catch (error: IllegalArgumentException) { + Timber.w(error) false } } @@ -53,6 +57,7 @@ private fun String.isValidNpub(): Boolean { val decoded = Bech32.decodeBytes(this) decoded.first == "npub" && this.length >= NPUB_LENGTH } catch (error: IllegalArgumentException) { + Timber.w(error) false } } diff --git a/app/src/main/kotlin/net/primal/android/discuss/feed/FeedViewModel.kt b/app/src/main/kotlin/net/primal/android/discuss/feed/FeedViewModel.kt index 3790f93a..8809bed2 100644 --- a/app/src/main/kotlin/net/primal/android/discuss/feed/FeedViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/discuss/feed/FeedViewModel.kt @@ -44,6 +44,7 @@ import net.primal.android.wallet.zaps.InvalidZapRequestException import net.primal.android.wallet.zaps.ZapFailureException import net.primal.android.wallet.zaps.ZapHandler import net.primal.android.wallet.zaps.hasWallet +import timber.log.Timber @HiltViewModel class FeedViewModel @Inject constructor( @@ -197,8 +198,10 @@ class FeedViewModel @Inject constructor( postAuthorId = postLikeAction.postAuthorId, ) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = FeedError.FailedToPublishLikeEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = FeedError.MissingRelaysConfiguration(error)) } } @@ -212,8 +215,10 @@ class FeedViewModel @Inject constructor( postRawNostrEvent = repostAction.postNostrEvent, ) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = FeedError.FailedToPublishRepostEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = FeedError.MissingRelaysConfiguration(error)) } } @@ -241,10 +246,13 @@ class FeedViewModel @Inject constructor( ), ) } catch (error: ZapFailureException) { + Timber.w(error) setErrorState(error = FeedError.FailedToPublishZapEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = FeedError.MissingRelaysConfiguration(error)) } catch (error: InvalidZapRequestException) { + Timber.w(error) setErrorState(error = FeedError.InvalidZapRequest(error)) } } @@ -257,8 +265,10 @@ class FeedViewModel @Inject constructor( mutedUserId = action.userId, ) } catch (error: WssException) { + Timber.w(error) setErrorState(error = FeedError.FailedToMuteUser(error)) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = FeedError.FailedToMuteUser(error)) } } diff --git a/app/src/main/kotlin/net/primal/android/discuss/list/FeedListViewModel.kt b/app/src/main/kotlin/net/primal/android/discuss/list/FeedListViewModel.kt index 7172003d..69444786 100644 --- a/app/src/main/kotlin/net/primal/android/discuss/list/FeedListViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/discuss/list/FeedListViewModel.kt @@ -54,7 +54,7 @@ class FeedListViewModel @Inject constructor( settingsRepository.fetchAndPersistAppSettings(userId = activeAccountStore.activeUserId()) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } diff --git a/app/src/main/kotlin/net/primal/android/editor/NoteEditorViewModel.kt b/app/src/main/kotlin/net/primal/android/editor/NoteEditorViewModel.kt index 6b340cdc..e5d98c75 100644 --- a/app/src/main/kotlin/net/primal/android/editor/NoteEditorViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/editor/NoteEditorViewModel.kt @@ -127,7 +127,7 @@ class NoteEditorViewModel @Inject constructor( feedRepository.fetchReplies(postId = replyToNoteId) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } @@ -146,11 +146,11 @@ class NoteEditorViewModel @Inject constructor( ) sendEffect(SideEffect.PostPublished) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = UiState.NewPostError.PublishError(cause = error.cause)) } catch (error: MissingRelaysException) { - setErrorState( - error = UiState.NewPostError.MissingRelaysConfiguration(cause = error), - ) + Timber.w(error) + setErrorState(error = UiState.NewPostError.MissingRelaysConfiguration(cause = error)) } finally { setState { copy(publishing = false) } } @@ -189,6 +189,7 @@ class NoteEditorViewModel @Inject constructor( ) } } catch (error: UnsuccessfulFileUpload) { + Timber.w(error) updateNoteAttachmentState(attachment = attachment.copy(uploadError = error)) } } diff --git a/app/src/main/kotlin/net/primal/android/explore/feed/ExploreFeedViewModel.kt b/app/src/main/kotlin/net/primal/android/explore/feed/ExploreFeedViewModel.kt index 5606f7df..1f848c8e 100644 --- a/app/src/main/kotlin/net/primal/android/explore/feed/ExploreFeedViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/explore/feed/ExploreFeedViewModel.kt @@ -39,6 +39,7 @@ import net.primal.android.wallet.zaps.InvalidZapRequestException import net.primal.android.wallet.zaps.ZapFailureException import net.primal.android.wallet.zaps.ZapHandler import net.primal.android.wallet.zaps.hasWallet +import timber.log.Timber @HiltViewModel class ExploreFeedViewModel @Inject constructor( @@ -128,6 +129,7 @@ class ExploreFeedViewModel @Inject constructor( directive = exploreQuery, ) } catch (error: WssException) { + Timber.w(error) setErrorState(error = ExploreFeedError.FailedToAddToFeed(error)) } } @@ -139,6 +141,7 @@ class ExploreFeedViewModel @Inject constructor( directive = exploreQuery, ) } catch (error: WssException) { + Timber.w(error) setErrorState(error = ExploreFeedError.FailedToRemoveFeed(error)) } } @@ -151,8 +154,10 @@ class ExploreFeedViewModel @Inject constructor( postAuthorId = postLikeAction.postAuthorId, ) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ExploreFeedError.FailedToPublishLikeEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ExploreFeedError.MissingRelaysConfiguration(error)) } } @@ -166,8 +171,10 @@ class ExploreFeedViewModel @Inject constructor( postRawNostrEvent = repostAction.postNostrEvent, ) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ExploreFeedError.FailedToPublishRepostEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ExploreFeedError.MissingRelaysConfiguration(error)) } } @@ -197,10 +204,13 @@ class ExploreFeedViewModel @Inject constructor( ), ) } catch (error: ZapFailureException) { + Timber.w(error) setErrorState(error = ExploreFeedError.FailedToPublishZapEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ExploreFeedError.MissingRelaysConfiguration(error)) } catch (error: InvalidZapRequestException) { + Timber.w(error) setErrorState(error = ExploreFeedError.InvalidZapRequest(error)) } } @@ -213,8 +223,10 @@ class ExploreFeedViewModel @Inject constructor( mutedUserId = action.profileId, ) } catch (error: WssException) { + Timber.w(error) setErrorState(error = ExploreFeedError.FailedToMuteUser(error)) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ExploreFeedError.FailedToMuteUser(error)) } } diff --git a/app/src/main/kotlin/net/primal/android/explore/home/ExploreHomeViewModel.kt b/app/src/main/kotlin/net/primal/android/explore/home/ExploreHomeViewModel.kt index b53cfde2..45c8b435 100644 --- a/app/src/main/kotlin/net/primal/android/explore/home/ExploreHomeViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/explore/home/ExploreHomeViewModel.kt @@ -83,7 +83,7 @@ class ExploreHomeViewModel @Inject constructor( try { exploreRepository.fetchTrendingHashtags() } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } finally { setState { copy(refreshing = false) } } diff --git a/app/src/main/kotlin/net/primal/android/explore/search/SearchViewModel.kt b/app/src/main/kotlin/net/primal/android/explore/search/SearchViewModel.kt index 66132260..99ca137f 100644 --- a/app/src/main/kotlin/net/primal/android/explore/search/SearchViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/explore/search/SearchViewModel.kt @@ -20,6 +20,7 @@ import net.primal.android.explore.search.SearchContract.UiEvent import net.primal.android.explore.search.SearchContract.UiState import net.primal.android.explore.search.ui.UserProfileUi import net.primal.android.networking.sockets.errors.WssException +import timber.log.Timber @HiltViewModel class SearchViewModel @Inject constructor( @@ -67,7 +68,7 @@ class SearchViewModel @Inject constructor( val result = exploreRepository.searchUsers(query = query) setState { copy(searchResults = result.map { it.mapAsUserProfileUi() }) } } catch (error: WssException) { - // Ignoring errors for now + Timber.w(error) } finally { setState { copy(searching = false) } } diff --git a/app/src/main/kotlin/net/primal/android/feed/api/mediator/FeedRemoteMediator.kt b/app/src/main/kotlin/net/primal/android/feed/api/mediator/FeedRemoteMediator.kt index d2f4180b..07027a54 100644 --- a/app/src/main/kotlin/net/primal/android/feed/api/mediator/FeedRemoteMediator.kt +++ b/app/src/main/kotlin/net/primal/android/feed/api/mediator/FeedRemoteMediator.kt @@ -28,6 +28,7 @@ import net.primal.android.networking.sockets.errors.NostrNoticeException import net.primal.android.networking.sockets.errors.WssException import net.primal.android.nostr.model.NostrEvent import net.primal.android.nostr.model.primal.content.ContentPrimalPaging +import timber.log.Timber @ExperimentalPagingApi class FeedRemoteMediator( @@ -166,6 +167,7 @@ class FeedRemoteMediator( val feedResponse = try { withContext(dispatcherProvider.io()) { feedApi.getFeed(body = feedRequestBody) } } catch (error: WssException) { + Timber.w(error) return MediatorResult.Error(error) } @@ -209,10 +211,12 @@ class FeedRemoteMediator( } MediatorResult.Success(endOfPaginationReached = false) - } catch (e: IOException) { - MediatorResult.Error(e) - } catch (e: NostrNoticeException) { - MediatorResult.Error(e) + } catch (error: IOException) { + Timber.w(error) + MediatorResult.Error(error) + } catch (error: NostrNoticeException) { + Timber.w(error) + MediatorResult.Error(error) } } diff --git a/app/src/main/kotlin/net/primal/android/feed/repository/PostRepository.kt b/app/src/main/kotlin/net/primal/android/feed/repository/PostRepository.kt index d73e50ab..a948e9a8 100644 --- a/app/src/main/kotlin/net/primal/android/feed/repository/PostRepository.kt +++ b/app/src/main/kotlin/net/primal/android/feed/repository/PostRepository.kt @@ -20,6 +20,7 @@ import net.primal.android.nostr.ext.parseHashtagTags import net.primal.android.nostr.ext.parsePubkeyTags import net.primal.android.nostr.notary.NostrNotary import net.primal.android.user.accounts.active.ActiveAccountStore +import timber.log.Timber class PostRepository @Inject constructor( private val database: PrimalDatabase, @@ -45,6 +46,7 @@ class PostRepository @Inject constructor( ), ) } catch (error: NostrPublishException) { + Timber.w(error) statsUpdater.revertStats() throw error } @@ -70,6 +72,7 @@ class PostRepository @Inject constructor( ), ) } catch (error: NostrPublishException) { + Timber.w(error) statsUpdater.revertStats() throw error } @@ -138,6 +141,7 @@ class PostRepository @Inject constructor( return try { primalImportApi.importEvents(events = listOf(noteEvent)) } catch (error: WssException) { + Timber.w(error) false } } diff --git a/app/src/main/kotlin/net/primal/android/messages/api/mediator/MessagesProcessor.kt b/app/src/main/kotlin/net/primal/android/messages/api/mediator/MessagesProcessor.kt index 79f12180..4f40598f 100644 --- a/app/src/main/kotlin/net/primal/android/messages/api/mediator/MessagesProcessor.kt +++ b/app/src/main/kotlin/net/primal/android/messages/api/mediator/MessagesProcessor.kt @@ -74,7 +74,7 @@ class MessagesProcessor @Inject constructor( ) response.posts.mapAsPostDataPO(referencedPosts = referencedPostsWithReplies) } catch (error: WssException) { - Timber.e(error) + Timber.w(error) emptyList() } } else { @@ -99,7 +99,7 @@ class MessagesProcessor @Inject constructor( database.profiles().upsertAll(data = profiles) profiles } catch (error: WssException) { - Timber.e(error) + Timber.w(error) emptyList() } } else { diff --git a/app/src/main/kotlin/net/primal/android/messages/api/mediator/MessagesRemoteMediator.kt b/app/src/main/kotlin/net/primal/android/messages/api/mediator/MessagesRemoteMediator.kt index 26079e4a..ce5cd53f 100644 --- a/app/src/main/kotlin/net/primal/android/messages/api/mediator/MessagesRemoteMediator.kt +++ b/app/src/main/kotlin/net/primal/android/messages/api/mediator/MessagesRemoteMediator.kt @@ -12,6 +12,7 @@ import net.primal.android.messages.api.MessagesApi import net.primal.android.messages.api.model.MessagesRequestBody import net.primal.android.messages.db.DirectMessage import net.primal.android.networking.sockets.errors.WssException +import timber.log.Timber @ExperimentalPagingApi class MessagesRemoteMediator( @@ -73,6 +74,7 @@ class MessagesRemoteMediator( messagesApi.getMessages(body = requestBody) } } catch (error: WssException) { + Timber.w(error) return MediatorResult.Error(error) } diff --git a/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListViewModel.kt b/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListViewModel.kt index 0be233c5..e2767def 100644 --- a/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/messages/conversation/MessageConversationListViewModel.kt @@ -115,7 +115,7 @@ class MessageConversationListViewModel @Inject constructor( } } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } diff --git a/app/src/main/kotlin/net/primal/android/networking/primal/PrimalSocketSubscription.kt b/app/src/main/kotlin/net/primal/android/networking/primal/PrimalSocketSubscription.kt index af175b76..215b935d 100644 --- a/app/src/main/kotlin/net/primal/android/networking/primal/PrimalSocketSubscription.kt +++ b/app/src/main/kotlin/net/primal/android/networking/primal/PrimalSocketSubscription.kt @@ -39,7 +39,7 @@ class PrimalSocketSubscription private constructor( try { subscribe() } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } } diff --git a/app/src/main/kotlin/net/primal/android/networking/relays/RelayPool.kt b/app/src/main/kotlin/net/primal/android/networking/relays/RelayPool.kt index 01daf728..c9334b35 100644 --- a/app/src/main/kotlin/net/primal/android/networking/relays/RelayPool.kt +++ b/app/src/main/kotlin/net/primal/android/networking/relays/RelayPool.kt @@ -25,6 +25,7 @@ import net.primal.android.nostr.model.NostrEvent import net.primal.android.user.domain.Relay import okhttp3.OkHttpClient import okhttp3.Request +import timber.log.Timber class RelayPool @AssistedInject constructor( private val dispatchers: CoroutineDispatcherProvider, @@ -58,6 +59,7 @@ class RelayPool @AssistedInject constructor( .addHeader("User-Agent", UserAgentProvider.USER_AGENT) .build() } catch (error: IllegalArgumentException) { + Timber.w(error) null } @@ -108,8 +110,10 @@ class RelayPool @AssistedInject constructor( val response = collectPublishResponse(eventId = nostrEvent.id) responseFlow.emit(NostrPublishResult(result = response)) } catch (error: NostrNoticeException) { + Timber.w(error) responseFlow.emit(NostrPublishResult(error = error)) } catch (error: TimeoutCancellationException) { + Timber.w(error) responseFlow.emit(NostrPublishResult(error = error)) } } diff --git a/app/src/main/kotlin/net/primal/android/networking/sockets/NostrIncomingMessageParser.kt b/app/src/main/kotlin/net/primal/android/networking/sockets/NostrIncomingMessageParser.kt index b1f6bd20..29f3323b 100644 --- a/app/src/main/kotlin/net/primal/android/networking/sockets/NostrIncomingMessageParser.kt +++ b/app/src/main/kotlin/net/primal/android/networking/sockets/NostrIncomingMessageParser.kt @@ -32,7 +32,7 @@ fun String.parseIncomingMessage(): NostrIncomingMessage? { NostrVerb.Incoming.COUNT -> jsonArray.takeAsCountIncomingMessage() } } catch (error: Exception) { - Timber.e(error) + Timber.w(error) null } } @@ -104,7 +104,7 @@ private fun JsonArray.takeAsNoticeIncomingMessage(): NostrIncomingMessage { try { UUID.fromString(it.jsonPrimitive.content) } catch (error: IllegalArgumentException) { - Timber.e(error) + Timber.w(error) null } } diff --git a/app/src/main/kotlin/net/primal/android/nostr/ext/NostrEvents.kt b/app/src/main/kotlin/net/primal/android/nostr/ext/NostrEvents.kt index 9183be4b..1444c695 100644 --- a/app/src/main/kotlin/net/primal/android/nostr/ext/NostrEvents.kt +++ b/app/src/main/kotlin/net/primal/android/nostr/ext/NostrEvents.kt @@ -5,11 +5,13 @@ import kotlinx.serialization.json.decodeFromJsonElement import net.primal.android.core.serialization.json.NostrJson import net.primal.android.nostr.model.NostrEvent import net.primal.android.nostr.model.primal.PrimalEvent +import timber.log.Timber fun JsonObject?.asNostrEventOrNull(): NostrEvent? { return try { if (this != null) NostrJson.decodeFromJsonElement(this) else null } catch (error: IllegalArgumentException) { + Timber.w(error) null } } @@ -18,6 +20,7 @@ fun JsonObject?.asPrimalEventOrNull(): PrimalEvent? { return try { if (this != null) NostrJson.decodeFromJsonElement(this) else null } catch (error: IllegalArgumentException) { + Timber.w(error) null } } diff --git a/app/src/main/kotlin/net/primal/android/nostr/ext/NostrResources.kt b/app/src/main/kotlin/net/primal/android/nostr/ext/NostrResources.kt index 86248d4d..f2dd1a1b 100644 --- a/app/src/main/kotlin/net/primal/android/nostr/ext/NostrResources.kt +++ b/app/src/main/kotlin/net/primal/android/nostr/ext/NostrResources.kt @@ -97,7 +97,7 @@ fun String.extractProfileId(): String? { else -> null } } catch (error: IllegalArgumentException) { - Timber.e(error) + Timber.w(error) null } } @@ -119,7 +119,7 @@ fun String.extractNoteId(): String? { else -> null } } catch (error: IllegalArgumentException) { - Timber.e(error) + Timber.w(error) null } } diff --git a/app/src/main/kotlin/net/primal/android/nostr/ext/PrimalEvents.kt b/app/src/main/kotlin/net/primal/android/nostr/ext/PrimalEvents.kt index a229c775..6389167a 100644 --- a/app/src/main/kotlin/net/primal/android/nostr/ext/PrimalEvents.kt +++ b/app/src/main/kotlin/net/primal/android/nostr/ext/PrimalEvents.kt @@ -13,7 +13,7 @@ inline fun PrimalEvent?.takeContentOrNull(): T? { NostrJson.parseToJsonElement(this.content), ) } catch (error: IllegalArgumentException) { - Timber.e(error) + Timber.w(error) null } } diff --git a/app/src/main/kotlin/net/primal/android/nostr/notary/NostrNotary.kt b/app/src/main/kotlin/net/primal/android/nostr/notary/NostrNotary.kt index c66af6c9..599348b5 100644 --- a/app/src/main/kotlin/net/primal/android/nostr/notary/NostrNotary.kt +++ b/app/src/main/kotlin/net/primal/android/nostr/notary/NostrNotary.kt @@ -26,6 +26,7 @@ import net.primal.android.user.domain.toZapTag import net.primal.android.wallet.domain.ZapTarget import net.primal.android.wallet.nwc.model.NwcWalletRequest import net.primal.android.wallet.nwc.model.PayInvoiceRequest +import timber.log.Timber class NostrNotary @Inject constructor( private val credentialsStore: CredentialsStore, @@ -36,6 +37,7 @@ class NostrNotary @Inject constructor( val npub = Hex.decode(pubkey).toNpub() credentialsStore.findOrThrow(npub = npub).nsec } catch (error: IllegalArgumentException) { + Timber.w(error) throw NostrSignUnauthorized() } } diff --git a/app/src/main/kotlin/net/primal/android/profile/details/ProfileScreen.kt b/app/src/main/kotlin/net/primal/android/profile/details/ProfileScreen.kt index 5de145be..e1ae2a90 100644 --- a/app/src/main/kotlin/net/primal/android/profile/details/ProfileScreen.kt +++ b/app/src/main/kotlin/net/primal/android/profile/details/ProfileScreen.kt @@ -128,6 +128,7 @@ import net.primal.android.theme.PrimalTheme import net.primal.android.theme.domain.PrimalTheme import net.primal.android.wallet.transactions.send.create.DraftTransaction import net.primal.android.wallet.utils.isLightningAddress +import timber.log.Timber @Composable fun ProfileScreen( @@ -700,6 +701,7 @@ private fun UserProfileDetails( try { localUriHandler.openUri(profileDetails.website) } catch (error: ActivityNotFoundException) { + Timber.w(error) uiScope.launch { Toast.makeText( context, diff --git a/app/src/main/kotlin/net/primal/android/profile/details/ProfileViewModel.kt b/app/src/main/kotlin/net/primal/android/profile/details/ProfileViewModel.kt index ab504f4e..37ec6f69 100644 --- a/app/src/main/kotlin/net/primal/android/profile/details/ProfileViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/profile/details/ProfileViewModel.kt @@ -152,7 +152,7 @@ class ProfileViewModel @Inject constructor( ) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } @@ -163,7 +163,7 @@ class ProfileViewModel @Inject constructor( profileRepository.requestProfileUpdate(profileId = profileId) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } @@ -175,8 +175,10 @@ class ProfileViewModel @Inject constructor( postAuthorId = postLikeAction.postAuthorId, ) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ProfileError.FailedToPublishLikeEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ProfileError.MissingRelaysConfiguration(error)) } } @@ -190,8 +192,10 @@ class ProfileViewModel @Inject constructor( postRawNostrEvent = repostAction.postNostrEvent, ) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ProfileError.FailedToPublishRepostEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ProfileError.MissingRelaysConfiguration(error)) } } @@ -219,10 +223,13 @@ class ProfileViewModel @Inject constructor( ), ) } catch (error: ZapFailureException) { + Timber.w(error) setErrorState(error = ProfileError.FailedToPublishZapEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ProfileError.MissingRelaysConfiguration(error)) } catch (error: InvalidZapRequestException) { + Timber.w(error) setErrorState(error = ProfileError.InvalidZapRequest(error)) } } @@ -235,10 +242,13 @@ class ProfileViewModel @Inject constructor( followedUserId = followAction.profileId, ) } catch (error: WssException) { + Timber.w(error) setErrorState(error = ProfileError.FailedToFollowProfile(error)) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ProfileError.FailedToFollowProfile(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ProfileError.MissingRelaysConfiguration(error)) } } @@ -251,10 +261,13 @@ class ProfileViewModel @Inject constructor( unfollowedUserId = unfollowAction.profileId, ) } catch (error: WssException) { + Timber.w(error) setErrorState(error = ProfileError.FailedToUnfollowProfile(error)) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ProfileError.FailedToUnfollowProfile(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ProfileError.MissingRelaysConfiguration(error)) } } diff --git a/app/src/main/kotlin/net/primal/android/profile/edit/EditProfileViewModel.kt b/app/src/main/kotlin/net/primal/android/profile/edit/EditProfileViewModel.kt index 8599282e..999fe1d1 100644 --- a/app/src/main/kotlin/net/primal/android/profile/edit/EditProfileViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/profile/edit/EditProfileViewModel.kt @@ -23,6 +23,7 @@ import net.primal.android.profile.edit.EditProfileContract.UiState.EditProfileEr import net.primal.android.profile.repository.ProfileRepository import net.primal.android.user.accounts.active.ActiveAccountStore import net.primal.android.user.repository.UserRepository +import timber.log.Timber @HiltViewModel class EditProfileViewModel @Inject constructor( @@ -123,7 +124,7 @@ class EditProfileViewModel @Inject constructor( try { profileRepository.requestProfileUpdate(profileId = profileId) } catch (error: WssException) { - // Ignore + Timber.w(error) } } @@ -135,10 +136,13 @@ class EditProfileViewModel @Inject constructor( userRepository.setProfileMetadata(userId = profileId, profileMetadata = profile) setEffect(effect = EditProfileContract.SideEffect.AccountSuccessfulyEdited) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = EditProfileError.FailedToPublishMetadata(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = EditProfileError.MissingRelaysConfiguration(error)) } catch (error: UnsuccessfulFileUpload) { + Timber.w(error) setErrorState(error = EditProfileError.FailedToUploadImage(error)) } finally { setState { copy(loading = false) } diff --git a/app/src/main/kotlin/net/primal/android/security/StreamExtensions.kt b/app/src/main/kotlin/net/primal/android/security/StreamExtensions.kt index 7b1dc394..4ff8d73c 100644 --- a/app/src/main/kotlin/net/primal/android/security/StreamExtensions.kt +++ b/app/src/main/kotlin/net/primal/android/security/StreamExtensions.kt @@ -13,10 +13,10 @@ inline fun InputStream.readDecrypted(json: Json, encryption: Encrypt return try { json.decodeFromString(decryptedJson) } catch (error: SerializationException) { - Timber.e(error) + Timber.w(error) throw CorruptionException("Unable to deserialize decrypted value.", error) } catch (error: IllegalArgumentException) { - Timber.e(error) + Timber.w(error) throw CorruptionException("Unable to deserialize decrypted value.", error) } } diff --git a/app/src/main/kotlin/net/primal/android/settings/notifications/NotificationsSettingsViewModel.kt b/app/src/main/kotlin/net/primal/android/settings/notifications/NotificationsSettingsViewModel.kt index 79eb5716..871fa8e0 100644 --- a/app/src/main/kotlin/net/primal/android/settings/notifications/NotificationsSettingsViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/settings/notifications/NotificationsSettingsViewModel.kt @@ -119,7 +119,7 @@ class NotificationsSettingsViewModel @Inject constructor( settingsRepository.fetchAndPersistAppSettings(userId = activeAccountStore.activeUserId()) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) setState { copy(error = FetchAppSettingsError(cause = error)) } } } diff --git a/app/src/main/kotlin/net/primal/android/settings/wallet/WalletSettingsViewModel.kt b/app/src/main/kotlin/net/primal/android/settings/wallet/WalletSettingsViewModel.kt index 8c0b39a2..478b99c3 100644 --- a/app/src/main/kotlin/net/primal/android/settings/wallet/WalletSettingsViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/settings/wallet/WalletSettingsViewModel.kt @@ -99,7 +99,7 @@ class WalletSettingsViewModel @Inject constructor( ) } } catch (error: NWCParseException) { - Timber.e(error) + Timber.w(error) } } diff --git a/app/src/main/kotlin/net/primal/android/settings/zaps/ZapSettingsViewModel.kt b/app/src/main/kotlin/net/primal/android/settings/zaps/ZapSettingsViewModel.kt index b85527ae..e1aec749 100644 --- a/app/src/main/kotlin/net/primal/android/settings/zaps/ZapSettingsViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/settings/zaps/ZapSettingsViewModel.kt @@ -87,7 +87,7 @@ class ZapSettingsViewModel @Inject constructor( settingsRepository.fetchAndPersistAppSettings(userId = activeAccountStore.activeUserId()) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } @@ -102,7 +102,7 @@ class ZapSettingsViewModel @Inject constructor( ) setState { copy(editPresetIndex = null) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } finally { setState { copy(saving = false) } } @@ -120,7 +120,7 @@ class ZapSettingsViewModel @Inject constructor( ) setState { copy(editPresetIndex = null) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } finally { setState { copy(saving = false) } } diff --git a/app/src/main/kotlin/net/primal/android/thread/ThreadViewModel.kt b/app/src/main/kotlin/net/primal/android/thread/ThreadViewModel.kt index a36a5bf0..2c3cfe41 100644 --- a/app/src/main/kotlin/net/primal/android/thread/ThreadViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/thread/ThreadViewModel.kt @@ -149,7 +149,7 @@ class ThreadViewModel @Inject constructor( feedRepository.fetchReplies(postId = postId) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } @@ -161,8 +161,10 @@ class ThreadViewModel @Inject constructor( postAuthorId = postLikeAction.postAuthorId, ) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ThreadError.FailedToPublishLikeEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ThreadError.MissingRelaysConfiguration(error)) } } @@ -176,8 +178,10 @@ class ThreadViewModel @Inject constructor( postRawNostrEvent = repostAction.postNostrEvent, ) } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ThreadError.FailedToPublishRepostEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ThreadError.MissingRelaysConfiguration(error)) } } @@ -205,10 +209,13 @@ class ThreadViewModel @Inject constructor( ), ) } catch (error: ZapFailureException) { + Timber.w(error) setErrorState(error = ThreadError.FailedToPublishZapEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ThreadError.MissingRelaysConfiguration(error)) } catch (error: InvalidZapRequestException) { + Timber.w(error) setErrorState(error = ThreadError.InvalidZapRequest(error)) } } @@ -237,8 +244,10 @@ class ThreadViewModel @Inject constructor( setState { copy(replyText = "") } } catch (error: NostrPublishException) { + Timber.w(error) setErrorState(error = ThreadError.FailedToPublishReplyEvent(error)) } catch (error: MissingRelaysException) { + Timber.w(error) setErrorState(error = ThreadError.MissingRelaysConfiguration(error)) } finally { setState { copy(publishingReply = false) } diff --git a/app/src/main/kotlin/net/primal/android/user/accounts/Parsers.kt b/app/src/main/kotlin/net/primal/android/user/accounts/Parsers.kt index 4f23e7e8..decf359d 100644 --- a/app/src/main/kotlin/net/primal/android/user/accounts/Parsers.kt +++ b/app/src/main/kotlin/net/primal/android/user/accounts/Parsers.kt @@ -7,11 +7,13 @@ import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive import net.primal.android.core.serialization.json.NostrJson import net.primal.android.user.domain.Relay +import timber.log.Timber fun String.parseRelays(): List { val jsonContent = try { NostrJson.parseToJsonElement(this) } catch (error: SerializationException) { + Timber.w(error) null } diff --git a/app/src/main/kotlin/net/primal/android/user/credentials/CredentialsStore.kt b/app/src/main/kotlin/net/primal/android/user/credentials/CredentialsStore.kt index 7a67d9da..d823ae74 100644 --- a/app/src/main/kotlin/net/primal/android/user/credentials/CredentialsStore.kt +++ b/app/src/main/kotlin/net/primal/android/user/credentials/CredentialsStore.kt @@ -16,6 +16,7 @@ import net.primal.android.crypto.toHex import net.primal.android.crypto.toNpub import net.primal.android.user.domain.Credential import org.spongycastle.util.encoders.DecoderException +import timber.log.Timber @Singleton class CredentialsStore @Inject constructor( @@ -54,8 +55,10 @@ class CredentialsStore @Inject constructor( val pubkey = CryptoUtils.publicKeyCreate(decoded.second) nsec to pubkey } catch (error: IllegalArgumentException) { + Timber.w(error) throw InvalidNostrKeyException() } catch (error: DecoderException) { + Timber.w(error) throw InvalidNostrKeyException() } } diff --git a/app/src/main/kotlin/net/primal/android/user/updater/UserDataUpdater.kt b/app/src/main/kotlin/net/primal/android/user/updater/UserDataUpdater.kt index 0340af21..fceaf0e0 100644 --- a/app/src/main/kotlin/net/primal/android/user/updater/UserDataUpdater.kt +++ b/app/src/main/kotlin/net/primal/android/user/updater/UserDataUpdater.kt @@ -29,7 +29,7 @@ class UserDataUpdater @AssistedInject constructor( updateData() lastTimeFetched = Instant.now() } catch (error: WssException) { - Timber.i(error) + Timber.w(error) } } } diff --git a/app/src/main/kotlin/net/primal/android/wallet/activation/WalletActivationScreen.kt b/app/src/main/kotlin/net/primal/android/wallet/activation/WalletActivationScreen.kt index c9dc17b7..617a0c33 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/activation/WalletActivationScreen.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/activation/WalletActivationScreen.kt @@ -90,6 +90,7 @@ import net.primal.android.wallet.activation.regions.toListOfCountries import net.primal.android.wallet.walletSuccessColor import net.primal.android.wallet.walletSuccessContentColor import net.primal.android.wallet.walletSuccessDimColor +import timber.log.Timber @OptIn(ExperimentalComposeUiApi::class, ExperimentalMaterial3Api::class) @Composable @@ -405,6 +406,7 @@ private fun rememberListOfCountries(): List { val regionsInputStream = try { assets.open("regions.json") } catch (error: IOException) { + Timber.w(error) return emptyList() } return remember { NostrJson.decodeFromStream(regionsInputStream).toListOfCountries() } diff --git a/app/src/main/kotlin/net/primal/android/wallet/activation/WalletActivationViewModel.kt b/app/src/main/kotlin/net/primal/android/wallet/activation/WalletActivationViewModel.kt index cd8e3d72..471b38c5 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/activation/WalletActivationViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/activation/WalletActivationViewModel.kt @@ -63,7 +63,7 @@ class WalletActivationViewModel @Inject constructor( ) setState { copy(status = WalletActivationStatus.PendingCodeConfirmation) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) setState { copy(error = error) } } finally { setState { copy(working = false) } @@ -93,7 +93,7 @@ class WalletActivationViewModel @Inject constructor( ) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) setState { copy(error = error) } } finally { setState { copy(working = false) } diff --git a/app/src/main/kotlin/net/primal/android/wallet/api/WalletApiImpl.kt b/app/src/main/kotlin/net/primal/android/wallet/api/WalletApiImpl.kt index 55e3c364..c994d17a 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/api/WalletApiImpl.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/api/WalletApiImpl.kt @@ -190,7 +190,7 @@ class WalletApiImpl @Inject constructor( try { NostrJson.decodeFromJsonElement(it) } catch (error: IllegalArgumentException) { - Timber.e(error) + Timber.w(error) null } } diff --git a/app/src/main/kotlin/net/primal/android/wallet/api/mediator/WalletTransactionsMediator.kt b/app/src/main/kotlin/net/primal/android/wallet/api/mediator/WalletTransactionsMediator.kt index f5b923a3..68c054ff 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/api/mediator/WalletTransactionsMediator.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/api/mediator/WalletTransactionsMediator.kt @@ -101,7 +101,7 @@ class WalletTransactionsMediator( try { usersApi.getUserProfilesMetadata(userIds = mentionedUserIds) } catch (error: WssException) { - Timber.e(error) + Timber.w(error) UserProfilesResponse() } } else { diff --git a/app/src/main/kotlin/net/primal/android/wallet/dashboard/WalletDashboardViewModel.kt b/app/src/main/kotlin/net/primal/android/wallet/dashboard/WalletDashboardViewModel.kt index 29ae8e43..155d09eb 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/dashboard/WalletDashboardViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/dashboard/WalletDashboardViewModel.kt @@ -109,7 +109,7 @@ class WalletDashboardViewModel @Inject constructor( try { walletRepository.fetchWalletBalance(userId = activeUserId) } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } } @@ -130,7 +130,7 @@ class WalletDashboardViewModel @Inject constructor( purchaseToken = purchase.purchaseToken, ) } catch (error: WssException) { - Timber.e(error) + Timber.w(error) val dashboardError = if (error.cause is NostrNoticeException) { UiState.DashboardError.InAppPurchaseNoticeError(message = error.message) } else { diff --git a/app/src/main/kotlin/net/primal/android/wallet/nwc/api/NwcApi.kt b/app/src/main/kotlin/net/primal/android/wallet/nwc/api/NwcApi.kt index 70aefe0c..0b2b3796 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/nwc/api/NwcApi.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/nwc/api/NwcApi.kt @@ -90,7 +90,7 @@ class NwcApi @Inject constructor( .multiply(thousandAsBigDecimal) .toLong() } catch (error: LnInvoiceUtils.AddressFormatException) { - Timber.e(error) + Timber.w(error) null } } diff --git a/app/src/main/kotlin/net/primal/android/wallet/store/inapp/InAppPurchaseBuyViewModel.kt b/app/src/main/kotlin/net/primal/android/wallet/store/inapp/InAppPurchaseBuyViewModel.kt index 73fbdf17..cceb2949 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/store/inapp/InAppPurchaseBuyViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/store/inapp/InAppPurchaseBuyViewModel.kt @@ -87,7 +87,7 @@ class InAppPurchaseBuyViewModel @Inject constructor( ) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) if (_state.value.quote == null) { setState { copy(error = error) } } @@ -112,7 +112,7 @@ class InAppPurchaseBuyViewModel @Inject constructor( primalBillingClient.launchMinSatsBillingFlow(quote = it, activity = event.activity) } } catch (error: InAppPurchaseException) { - Timber.e(error) + Timber.w(error) setState { copy(error = error) } } } diff --git a/app/src/main/kotlin/net/primal/android/wallet/transactions/details/TransactionDetailsScreen.kt b/app/src/main/kotlin/net/primal/android/wallet/transactions/details/TransactionDetailsScreen.kt index 8b064b29..ae5727a0 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/transactions/details/TransactionDetailsScreen.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/transactions/details/TransactionDetailsScreen.kt @@ -365,7 +365,7 @@ private fun TransactionCard(txData: TransactionDetailDataUi, onProfileClick: (St val formattedUsdAmount = try { numberFormat.format(usdAmount) } catch (error: IllegalArgumentException) { - Timber.e(error) + Timber.w(error) null } diff --git a/app/src/main/kotlin/net/primal/android/wallet/transactions/details/TransactionDetailsViewModel.kt b/app/src/main/kotlin/net/primal/android/wallet/transactions/details/TransactionDetailsViewModel.kt index 6074dea2..e5ceb50a 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/transactions/details/TransactionDetailsViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/transactions/details/TransactionDetailsViewModel.kt @@ -74,7 +74,7 @@ class TransactionDetailsViewModel @Inject constructor( feedRepository.fetchReplies(postId = noteId) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) } finally { setState { copy(loading = false) } } diff --git a/app/src/main/kotlin/net/primal/android/wallet/transactions/send/create/CreateTransactionViewModel.kt b/app/src/main/kotlin/net/primal/android/wallet/transactions/send/create/CreateTransactionViewModel.kt index 9513b3b2..0957f0dd 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/transactions/send/create/CreateTransactionViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/transactions/send/create/CreateTransactionViewModel.kt @@ -124,7 +124,7 @@ class CreateTransactionViewModel @Inject constructor( ) setState { copy(transaction = transaction.copy(status = TransactionStatus.Sent)) } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) setState { copy( error = error, diff --git a/app/src/main/kotlin/net/primal/android/wallet/transactions/send/prepare/SendPaymentViewModel.kt b/app/src/main/kotlin/net/primal/android/wallet/transactions/send/prepare/SendPaymentViewModel.kt index 9c592c51..ff6ca4a8 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/transactions/send/prepare/SendPaymentViewModel.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/transactions/send/prepare/SendPaymentViewModel.kt @@ -140,7 +140,7 @@ class SendPaymentViewModel @Inject constructor( } } } catch (error: WssException) { - Timber.e(error) + Timber.w(error) setState { copy(error = UiState.SendPaymentError.ParseException(error)) } } finally { setState { copy(parsing = false) } diff --git a/app/src/main/kotlin/net/primal/android/wallet/utils/LnInvoiceUtils.kt b/app/src/main/kotlin/net/primal/android/wallet/utils/LnInvoiceUtils.kt index 9be0c444..85d0558b 100644 --- a/app/src/main/kotlin/net/primal/android/wallet/utils/LnInvoiceUtils.kt +++ b/app/src/main/kotlin/net/primal/android/wallet/utils/LnInvoiceUtils.kt @@ -3,6 +3,7 @@ package net.primal.android.wallet.utils import java.math.BigDecimal import java.util.Locale import java.util.regex.Pattern +import timber.log.Timber // Made by Vitor Pamplona // https://github.com/vitorpamplona/amethyst/blob/main/quartz/src/main/java/com/vitorpamplona/quartz/encoders/LnInvoiceUtil.kt @@ -115,8 +116,9 @@ object LnInvoiceUtils { private fun getAmount(invoice: String): BigDecimal { try { decodeUnlimitedLength(invoice) // checksum must match - } catch (e: AddressFormatException) { - throw IllegalArgumentException("Cannot decode invoice: $invoice", e) + } catch (error: AddressFormatException) { + Timber.w(error) + throw IllegalArgumentException("Cannot decode invoice: $invoice", error) } val matcher = invoicePattern.matcher(invoice)