diff --git a/src/main/kotlin/org/gitanimals/coupon/controller/response/CouponResponse.kt b/src/main/kotlin/org/gitanimals/coupon/controller/response/CouponResponse.kt index b8c50a6..16ce976 100644 --- a/src/main/kotlin/org/gitanimals/coupon/controller/response/CouponResponse.kt +++ b/src/main/kotlin/org/gitanimals/coupon/controller/response/CouponResponse.kt @@ -2,6 +2,7 @@ package org.gitanimals.coupon.controller.response import org.gitanimals.coupon.domain.Coupon import java.time.LocalDateTime +import java.time.ZoneOffset data class CouponResponse( val id: String, @@ -16,7 +17,7 @@ data class CouponResponse( id = coupon.id.toString(), userId = coupon.userId.toString(), code = coupon.code, - usedAt = LocalDateTime.from(coupon.usedAt), + usedAt = LocalDateTime.ofInstant(coupon.usedAt, ZoneOffset.UTC), ) } } diff --git a/src/main/kotlin/org/gitanimals/coupon/infra/RestIdentityApi.kt b/src/main/kotlin/org/gitanimals/coupon/infra/RestIdentityApi.kt index cd65c5c..ff03382 100644 --- a/src/main/kotlin/org/gitanimals/coupon/infra/RestIdentityApi.kt +++ b/src/main/kotlin/org/gitanimals/coupon/infra/RestIdentityApi.kt @@ -16,8 +16,11 @@ class RestIdentityApi : IdentityApi { .uri("/users") .header(HttpHeaders.AUTHORIZATION, token) .exchange { _, response -> - response.bodyTo(UserResponse::class.java) - ?: throw IllegalArgumentException("Authorization failed") + runCatching { + response.bodyTo(UserResponse::class.java) + }.getOrElse { + throw IllegalArgumentException("Authorization failed", it) + } } } } diff --git a/src/main/kotlin/org/gitanimals/gotcha/infra/RestRenderApi.kt b/src/main/kotlin/org/gitanimals/gotcha/infra/RestRenderApi.kt index 21482d9..87e0615 100644 --- a/src/main/kotlin/org/gitanimals/gotcha/infra/RestRenderApi.kt +++ b/src/main/kotlin/org/gitanimals/gotcha/infra/RestRenderApi.kt @@ -21,9 +21,16 @@ class RestRenderApi( ) .exchange { _, response -> if (response.statusCode.is2xxSuccessful) { - return@exchange response.bodyTo(object : - ParameterizedTypeReference>() {})?.get("id") - ?: throw IllegalStateException("Create persona success but, cannot get persona-id") + return@exchange runCatching { + response.bodyTo(object : + ParameterizedTypeReference>() {})?.get("id") + }.getOrElse { + throw IllegalStateException( + "Create persona success but, cannot get persona-id", it + ) + } ?: throw IllegalStateException( + "Create persona success but, cannot get persona-id cause it's null" + ) } throw IllegalArgumentException("Cannot add persona name \"$personaName\" to user") } diff --git a/src/main/kotlin/org/gitanimals/gotcha/infra/RestUserApi.kt b/src/main/kotlin/org/gitanimals/gotcha/infra/RestUserApi.kt index e68f444..b64ed1d 100644 --- a/src/main/kotlin/org/gitanimals/gotcha/infra/RestUserApi.kt +++ b/src/main/kotlin/org/gitanimals/gotcha/infra/RestUserApi.kt @@ -17,8 +17,11 @@ class RestUserApi( .uri("/users") .header(HttpHeaders.AUTHORIZATION, token) .exchange { _, response -> - response.bodyTo(UserResponse::class.java) - ?: throw IllegalArgumentException("Authorization failed") + runCatching { + response.bodyTo(UserResponse::class.java) + }.getOrElse { + throw IllegalArgumentException("Authorization failed", it) + } } }