From 5b22f1850c6436bf261be91dc8d9b825f1e7d283 Mon Sep 17 00:00:00 2001 From: jhg3410 Date: Tue, 22 Oct 2024 22:37:13 +0900 Subject: [PATCH] =?UTF-8?q?MONEYMONG-511=20feature:=20ResultCallAdapter=20?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=98=88=EC=83=81=EC=B9=98=20=EB=AA=BB?= =?UTF-8?q?=ED=95=9C=20=EC=97=90=EB=9F=AC=20=EC=8A=A4=ED=8E=99=EC=9D=BC=20?= =?UTF-8?q?=EB=95=8C=EB=A5=BC=20=EB=8C=80=EB=B9=84=ED=95=B4=EC=84=9C=20try?= =?UTF-8?q?=20catch=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network/adapter/ResultCallAdapter.kt | 16 ++++++++++------ .../moneymong/network/response/ErrorResponse.kt | 1 - 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/network/src/main/java/com/moneymong/moneymong/network/adapter/ResultCallAdapter.kt b/core/network/src/main/java/com/moneymong/moneymong/network/adapter/ResultCallAdapter.kt index 0bd65743..eaf09456 100644 --- a/core/network/src/main/java/com/moneymong/moneymong/network/adapter/ResultCallAdapter.kt +++ b/core/network/src/main/java/com/moneymong/moneymong/network/adapter/ResultCallAdapter.kt @@ -48,12 +48,16 @@ private class ResultCall( return Result.failure(MoneyMongError.UnExpectedError) } - val errorResponse = fromJsonToErrorResponse(errorBody) - val httpError = getErrorByStatusCode( - statusCode = errorResponse.status, - message = errorResponse.message - ) - return Result.failure(httpError) + return try { + val errorResponse = fromJsonToErrorResponse(errorBody) + val httpError = getErrorByStatusCode( + statusCode = errorResponse.status, + message = errorResponse.message + ) + Result.failure(httpError) + } catch (e: Exception) { + Result.failure(MoneyMongError.UnExpectedError) + } } override fun onFailure(call: Call, t: Throwable) { diff --git a/core/network/src/main/java/com/moneymong/moneymong/network/response/ErrorResponse.kt b/core/network/src/main/java/com/moneymong/moneymong/network/response/ErrorResponse.kt index 0e070acb..51b304fd 100644 --- a/core/network/src/main/java/com/moneymong/moneymong/network/response/ErrorResponse.kt +++ b/core/network/src/main/java/com/moneymong/moneymong/network/response/ErrorResponse.kt @@ -1,7 +1,6 @@ package com.moneymong.moneymong.network.response import com.google.gson.Gson -import com.google.gson.annotations.SerializedName data class ErrorResponse( val status: Int,