Skip to content

Commit

Permalink
[AN/USER] refactor: 네트워크 에러 로깅을 확장함수 없이 직접 처리한다(#595) (#596)
Browse files Browse the repository at this point in the history
refactor: 네트워크 에러 로깅을 확장함수 없이 직접 처리한다
  • Loading branch information
SeongHoonC authored Nov 8, 2023
1 parent 0027082 commit 674c8ab
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?: "")
}
}
}
Expand All @@ -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)
Expand All @@ -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 ?: "")
}
}
}
Expand All @@ -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"
Expand Down

0 comments on commit 674c8ab

Please sign in to comment.