diff --git a/EATSSU/App/Sources/Presentation/Auth/Enum/NIcknameTextFieldResultType.swift b/EATSSU/App/Sources/Presentation/Auth/Enum/NIcknameTextFieldResultType.swift index 9b8dd48d..da7f1258 100644 --- a/EATSSU/App/Sources/Presentation/Auth/Enum/NIcknameTextFieldResultType.swift +++ b/EATSSU/App/Sources/Presentation/Auth/Enum/NIcknameTextFieldResultType.swift @@ -71,7 +71,7 @@ enum NicknameTextFieldResultType { case .nicknameTextFieldValid: .gray600 default: - .primary + .error } } diff --git a/EATSSU/App/Sources/Presentation/Auth/ViewController/SetNickNameViewController.swift b/EATSSU/App/Sources/Presentation/Auth/ViewController/SetNickNameViewController.swift index 0b4a3251..451033c1 100644 --- a/EATSSU/App/Sources/Presentation/Auth/ViewController/SetNickNameViewController.swift +++ b/EATSSU/App/Sources/Presentation/Auth/ViewController/SetNickNameViewController.swift @@ -322,9 +322,29 @@ extension SetNickNameViewController { self.updateSaveButtonState() case .failure(let error): - print("닉네임 중복 확인 실패: \(error.localizedDescription)") - RealmService.shared.resetDB() - self.navigateToLogin() + // 닉네임 중복 확인 실패 시 Error Handling + if let networkError = error as? NetworkError, + case .underlying(let moyaError) = networkError, + let response = (moyaError as? MoyaError)?.response, + response.statusCode == 400 { + do { + let errorResponse = try JSONDecoder().decode(BaseResponse.self, from: response.data) + DispatchQueue.main.async { + self.showToast(message: errorResponse.message, type: .danger) + self.setNickNameView.inputNickNameTextField.layer.borderColor = UIColor.error.cgColor + self.setNickNameView.nicknameValidationMessageLabel.text = errorResponse.message + self.setNickNameView.nicknameValidationMessageLabel.textColor = UIColor.error + } + } catch { + print("닉네임 에러 응답 디코딩 실패: \(error.localizedDescription)") + RealmService.shared.resetDB() + self.navigateToLogin() + } + } else { + // 그 외 모든 에러 처리 + RealmService.shared.resetDB() + self.navigateToLogin() + } } } }