From 76887ff8eef67adc0ef154f38e825e0da68ed127 Mon Sep 17 00:00:00 2001 From: Harrishan Date: Thu, 21 Nov 2024 12:11:18 +0100 Subject: [PATCH] fix: remove redundant try-catch in `deleteUserProfile` of `UserViewModel` --- .../periodpals/model/user/UserViewModel.kt | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/android/periodpals/model/user/UserViewModel.kt b/app/src/main/java/com/android/periodpals/model/user/UserViewModel.kt index 3f93ae22e..9a450c87c 100644 --- a/app/src/main/java/com/android/periodpals/model/user/UserViewModel.kt +++ b/app/src/main/java/com/android/periodpals/model/user/UserViewModel.kt @@ -94,21 +94,17 @@ class UserViewModel(private val userRepository: UserRepositorySupabase) : ViewMo } ) { viewModelScope.launch { - try { - userRepository.deleteUserProfile( - idUser, - onSuccess = { - Log.d(TAG, "deleteAccount: Success") - _user.value = null - onSuccess() - }, - onFailure = { exception -> - Log.d(TAG, "deleteAccount : fail to delete user: ${exception.message}") - onFailure(exception) - }) - } catch (e: Exception) { - onFailure(e) - } + userRepository.deleteUserProfile( + idUser, + onSuccess = { + Log.d(TAG, "deleteAccount: Success") + _user.value = null + onSuccess() + }, + onFailure = { exception -> + Log.d(TAG, "deleteAccount : fail to delete user: ${exception.message}") + onFailure(exception) + }) } } }