Skip to content

Commit

Permalink
feat #144: 코드리뷰-uppercase 변수명 lowercase 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
minsangKang committed Nov 24, 2024
1 parent bc51802 commit aa72f11
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 47 deletions.
60 changes: 30 additions & 30 deletions Project_Timer/Data/NetworkError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ import Moya

/// 네트워크 에러
enum NetworkError: Error {
case FAIL
case TIMEOUT
case DECODEERROR
case CLIENTERROR(String?) // 400
case AUTHENTICATION(String?) // 401
case NOTFOUND(String?) // 404
case CONFLICT(String?) // 409
case SERVERERROR(String?) // 500
case ERRORRESPONSE(TTErrorResponse) // TiTi ErrorResponse
case fail
case timeout
case decode
case client(String?) // 400
case authentication(String?) // 401
case notFound(String?) // 404
case conflict(String?) // 409
case server(String?) // 500
case errorResponse(TTErrorResponse) // TiTi ErrorResponse

static func serverError(statusCode: Int, data: Data? = nil) -> NetworkError {
// MARK: Decoding 로직 필요
let errorMessage: String? = ""
switch statusCode {
case 400:
return .CLIENTERROR(errorMessage)
return .client(errorMessage)
case 401:
return .AUTHENTICATION(errorMessage)
return .authentication(errorMessage)
case 404:
return .NOTFOUND(errorMessage)
return .notFound(errorMessage)
case 409:
return .CONFLICT(errorMessage)
return .conflict(errorMessage)
case 500:
return .SERVERERROR(errorMessage)
return .server(errorMessage)
default:
return .FAIL
return .fail
}
}

Expand All @@ -45,25 +45,25 @@ enum NetworkError: Error {
guard let errorResponse = try? JSONDecoder().decode(TTErrorResponse.self, from: response.data) else {
return .serverError(statusCode: response.statusCode)
}
return .ERRORRESPONSE(errorResponse)
return .errorResponse(errorResponse)
}

/// 범용적으로 표시될 수 있는 alert title 값, CLIENTERROR의 경우 VM에서 처리
var title: String {
switch self {
case .FAIL:
case .fail:
return Localized.string(.Server_Error_NetworkError)
case .TIMEOUT:
case .timeout:
return Localized.string(.Server_Error_NetworkTimeout)
case .DECODEERROR:
case .decode:
return Localized.string(.Server_Error_NetworkFetchError)
case .AUTHENTICATION(_):
case .authentication(_):
return Localized.string(.SignIn_Error_AuthenticationError)
case .NOTFOUND(_):
case .notFound(_):
return Localized.string(.Server_Error_NetworkFetchError)
case .CONFLICT(_):
case .conflict(_):
return Localized.string(.SignUp_Error_SignupError)
case .SERVERERROR(_):
case .server(_):
return Localized.string(.Server_Error_ServerError)
default:
return Localized.string(.Server_Error_NetworkError)
Expand All @@ -73,19 +73,19 @@ enum NetworkError: Error {
/// 범용적으로 표시될 수 있는 alert message 값, CLIENTERROR의 경우 VM에서 처리
var message: String {
switch self {
case .FAIL:
case .fail:
return Localized.string(.Server_Error_CheckNetwork)
case .TIMEOUT:
case .timeout:
return Localized.string(.Server_Error_CheckNetwork)
case .DECODEERROR:
case .decode:
return Localized.string(.Server_Error_DecodeError)
case .AUTHENTICATION(_):
case .authentication(_):
return Localized.string(.SignIn_Error_SigninAgain)
case .NOTFOUND(_):
case .notFound(_):
return Localized.string(.Server_Error_DecodeError)
case .CONFLICT(_):
case .conflict(_):
return Localized.string(.SignUp_Error_EnterDifferentValue)
case .SERVERERROR(_):
case .server(_):
return Localized.string(.Server_Error_ServerErrorTryAgain)
default:
return Localized.string(.Server_Error_CheckNetwork)
Expand Down
10 changes: 5 additions & 5 deletions Project_Timer/Data/TTProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ final class TTProvider<T: TargetType>: MoyaProvider<T> {
case .statusCode(let response):
return NetworkError.serverError(statusCode: response.statusCode)
default:
return NetworkError.FAIL
return NetworkError.fail
}
}
return NetworkError.FAIL
return NetworkError.fail
}
}

extension Publisher {
/// Repository의 공통적인 Decode 에러를 반환하는 Publisher
func catchDecodeError() -> AnyPublisher<Self.Output, NetworkError> {
return self
.mapError { error in return error as? NetworkError ?? .DECODEERROR }
.mapError { error in return error as? NetworkError ?? .decode }
.eraseToAnyPublisher()
}
}
Expand All @@ -69,11 +69,11 @@ extension Publisher where Output == Response, Failure == NetworkError {
let decodedData = try jsonDecoder.decode(D.self, from: response.data)
return decodedData
} catch {
throw NetworkError.DECODEERROR
throw NetworkError.decode
}
}
.mapError { error in
error as? NetworkError ?? NetworkError.FAIL
error as? NetworkError ?? NetworkError.fail
}
.eraseToAnyPublisher()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class GetAppVersionUseCase {

func execute() -> AnyPublisher<AppLatestVersionInfo, NetworkError> {
return self.repository.getAppVersion()
.flatMap { _ in Fail(error: NetworkError.FAIL) }
.flatMap { _ in Fail(error: NetworkError.fail) }
.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extension ResetPasswordEmailModel {
print("ERROR", #function, networkError)
self?.validEmail = false
switch networkError {
case .NOTFOUND(_):
case .notFound(_):
self?.errorMessage = .notExist
default:
self?.errorMessage = .serverError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension ResetPasswordNicknameModel {
print("ERROR", #function, networkError)
self?.validNickname = false
switch networkError {
case .NOTFOUND(_):
case .notFound(_):
self?.errorMessage = .notExist
default:
self?.errorMessage = .serverError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ extension ResetPasswordModel {
print("ERROR", #function, networkError)
self?.validPassword2 = false
switch networkError {
case .NOTFOUND(_):
case .notFound(_):
self?.errorMessage = .notExist
default:
self?.errorMessage = .serverError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class SignupSigninVM {
print("ERROR", #function, networkError)
switch networkError {
// signup 관련 error message 추가
case .CLIENTERROR(_):
case .client(_):
self?.alert = (title: Localized.string(.SignUp_Error_SignupError), text: Localized.string(.SignUp_Error_CheckNicknameOrEmail))
default:
self?.alert = networkError.alertMessage
Expand All @@ -69,10 +69,10 @@ final class SignupSigninVM {
print("ERROR", #function, networkError)
switch networkError {
// signin 관련 error message 추가
case .CLIENTERROR(_):
case .client(_):
self?.alert = (title: Localized.string(.SignIn_Error_SigninFail), text: Localized.string(.SignIn_Error_CheckNicknameOrPassword))
// TestServer 에러핸들링 이슈로 404코드 추가
case .NOTFOUND(_):
case .notFound(_):
self?.alert = (title: Localized.string(.SignIn_Error_SigninFail), text: Localized.string(.SignIn_Error_CheckNicknameOrPassword))
default:
self?.alert = networkError.alertMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extension SyncDailysVM {
print("ERROR", #function, networkError)
self?.loading = false
switch networkError {
case .CLIENTERROR(let message):
case .client(let message):
if let message = message {
print("[upload Dailys ERROR] \(message)")
}
Expand All @@ -114,7 +114,7 @@ extension SyncDailysVM {
print("ERROR", #function, networkError)
self?.loading = false
switch networkError {
case .CLIENTERROR(let message):
case .client(let message):
if let message = message {
print("[upload Recordtime ERROR] \(message)")
}
Expand Down Expand Up @@ -143,7 +143,7 @@ extension SyncDailysVM {
print("ERROR", #function, networkError)
self?.loading = false
switch networkError {
case .CLIENTERROR(let message):
case .client(let message):
if let message = message {
print("[get Dailys ERROR] \(message)")
}
Expand All @@ -170,7 +170,7 @@ extension SyncDailysVM {
print("ERROR", #function, networkError)
self?.loading = false
switch networkError {
case .CLIENTERROR(let message):
case .client(let message):
if let message = message {
print("[get RecordTimes ERROR] \(message)")
}
Expand All @@ -197,7 +197,7 @@ extension SyncDailysVM {
print("ERROR", #function, networkError)
self?.loading = false
switch networkError {
case .CLIENTERROR(let message):
case .client(let message):
if let message = message {
print("[get SyncLog ERROR] \(message)")
}
Expand Down

0 comments on commit aa72f11

Please sign in to comment.