From c59005d9e454899907f52df4fafcae8ef9aaccbf Mon Sep 17 00:00:00 2001 From: vrexpert Date: Wed, 1 Nov 2023 18:28:01 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=84=A4=ED=8A=B8=EC=9B=8C?= =?UTF-8?q?=ED=81=AC=20=EC=97=90=EB=9F=AC=20=EB=A1=9C=EA=B9=85=EC=9D=84=20?= =?UTF-8?q?=ED=99=95=EC=9E=A5=ED=95=A8=EC=88=98=20=EC=97=86=EC=9D=B4=20?= =?UTF-8?q?=EC=A7=81=EC=A0=91=20=EC=B2=98=EB=A6=AC=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ticketreserve/TicketReserveViewModel.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveViewModel.kt index 9f07761b3..fa558fc8d 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveViewModel.kt @@ -50,9 +50,9 @@ class TicketReserveViewModel @Inject constructor( ), stages = it.reservationStages.toTicketReserveItems(), ) - }.onFailure { throwable -> + }.onFailure { error -> _uiState.value = TicketReserveUiState.Error - throwable.logNetworkFailure(KEY_LOAD_RESERVATION_LOG) + analyticsHelper.logNetworkFailure(KEY_LOAD_RESERVATION_LOG, error.message ?: "") } } } @@ -68,9 +68,12 @@ class TicketReserveViewModel @Inject constructor( reservationTickets.sortedByTicketTypes(), ), ) - }.onFailure { throwable -> + }.onFailure { error -> _uiState.value = TicketReserveUiState.Error - throwable.logNetworkFailure(KEY_SHOW_TICKET_TYPES_LOG) + analyticsHelper.logNetworkFailure( + KEY_SHOW_TICKET_TYPES_LOG, + error.message ?: "", + ) } } else { _event.emit(TicketReserveEvent.ShowSignIn) @@ -83,12 +86,12 @@ class TicketReserveViewModel @Inject constructor( ticketRepository.reserveTicket(ticketId) .onSuccess { _event.emit(TicketReserveEvent.ReserveTicketSuccess(it)) - }.onFailure { throwable -> - if (throwable is ErrorCode) { - _event.emit(TicketReserveEvent.ReserveTicketFailed(throwable)) + }.onFailure { error -> + if (error is ErrorCode) { + _event.emit(TicketReserveEvent.ReserveTicketFailed(error)) } else { _event.emit(TicketReserveEvent.ReserveTicketFailed(ErrorCode.UNKNOWN())) - throwable.logNetworkFailure(KEY_RESERVE_TICKET) + analyticsHelper.logNetworkFailure(KEY_RESERVE_TICKET, error.message ?: "") } } } @@ -109,10 +112,6 @@ class TicketReserveViewModel @Inject constructor( it.toTicketReserveItem() } - private fun Throwable.logNetworkFailure(key: String) { - analyticsHelper.logNetworkFailure(key, message.toString()) - } - companion object { private const val KEY_LOAD_RESERVATION_LOG = "load_reservation"