Skip to content

Commit

Permalink
[#17] 통신을 위한 네트워크 관련 베이스 코드 작성 - 리뷰 반영
Browse files Browse the repository at this point in the history
- 클래스 구현부가 비어있는 경우 중괄호를 제거합니다.
- 네이밍 변경합니다.
  • Loading branch information
heechokim committed Apr 30, 2022
1 parent fc59d06 commit f91f1ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class MainActivity : AppCompatActivity() {
Lg.d("postman test Success response 2 ${response1.body.data}")
}
is ApiResult.Failure -> {
when (response1.exception) {
when (response1.throwable) {
is ApiException -> {
Lg.d("postman test Failure response 2 ${response1.exception.message}")
Lg.d("postman test Failure response 2 ${response1.throwable.message}")
}
}
}
Expand All @@ -38,9 +38,9 @@ class MainActivity : AppCompatActivity() {
Lg.d("postman test Success response 3 ${response2.body.data}")
}
is ApiResult.Failure -> {
when (response2.exception) {
when (response2.throwable) {
is ApiException -> {
Lg.d("postman test Failure response 2 ${response2.exception.message}")
Lg.d("postman test Failure response 2 ${response2.throwable.message}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ package com.moyerun.moyeorun_android.common.exceptions

import java.lang.RuntimeException

class NetworkException(message: String, cause: Throwable) : RuntimeException(message, cause) {

}
class NetworkException(message: String, cause: Throwable) : RuntimeException(message, cause)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.moyerun.moyeorun_android.network.calladapter

/**
* Success : API 호출 성공 시, body를 Wrapping 합니다.
* Failure : API 호출 실패 시, errorBody를 Wrpping 합니다.
* Failure : API 호출 실패 시, throwable을 Wrpping 합니다.
*/
sealed class ApiResult<out T> {
data class Success<T>(val body: T) : ApiResult<T>()
data class Failure(val exception: Throwable) : ApiResult<Nothing>()
data class Failure(val throwable: Throwable) : ApiResult<Nothing>()
}

0 comments on commit f91f1ce

Please sign in to comment.