Skip to content

Commit 316f1b7

Browse files
authored
Merge pull request #118 from MONEYMONG/refactor/error-code
Error case 수정
2 parents 8018ae7 + 98d8e3c commit 316f1b7

File tree

11 files changed

+99
-48
lines changed

11 files changed

+99
-48
lines changed

Projects/Core/MMNetwork/Sources/NetworkManager.swift

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ public final class NetworkManager: NetworkManagerInterfacae {
2929
{
3030
if let message = errorResponse.message {
3131
throw MoneyMongError.appError(
32-
MoneyMongError.Code(rawValue: errorResponse.code) ?? .default,
33-
errorMessage: message
32+
MoneyMongError.Code(rawValue: errorResponse.code) ?? .default
3433
)
3534
}
3635

3736
if let messages = errorResponse.messages {
3837
throw MoneyMongError.appError(
39-
MoneyMongError.Code(rawValue: errorResponse.code) ?? .default,
40-
errorMessage: messages.joined(separator: "\n")
38+
MoneyMongError.Code(rawValue: errorResponse.code) ?? .default
4139
)
4240
}
4341
}
@@ -98,22 +96,20 @@ public final class NetworkManager: NetworkManagerInterfacae {
9896
{
9997
if let message = errorResponse.message {
10098
throw MoneyMongError.appError(
101-
MoneyMongError.Code(rawValue: errorResponse.code) ?? .default,
102-
errorMessage: message
99+
MoneyMongError.Code(rawValue: errorResponse.code) ?? .default
103100
)
104101
}
105102

106103
if let messages = errorResponse.messages {
107104
throw MoneyMongError.appError(
108-
MoneyMongError.Code(rawValue: errorResponse.code) ?? .default,
109-
errorMessage: messages.joined(separator: "\n")
105+
MoneyMongError.Code(rawValue: errorResponse.code) ?? .default
110106
)
111107
}
112108
}
113109

114110
assertionFailure("dto디코딩, error디코딩 모두 실패 이러면 안되요 디버깅 해주세요")
115111

116-
throw MoneyMongError.appError(.default, errorMessage: "디코딩 실패")
112+
throw MoneyMongError.appError(.default)
117113
case let .failure(error):
118114
throw error
119115
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import Repository
2+
import MMNetworkInterface
3+
import Utility
24

35
public final class MockNetworkManager: NetworkManagerInterfacae {
46
public var returnValue: (any Responsable)?
@@ -7,16 +9,16 @@ public final class MockNetworkManager: NetworkManagerInterfacae {
79

810
public var requestCallCount: Int = 0
911

10-
public func request<DTO>(target: any Core.TargetType, of type: DTO.Type) async throws -> DTO where DTO : Core.Responsable {
12+
public func request<DTO>(target: any TargetType, of type: DTO.Type) async throws -> DTO where DTO : Responsable {
1113
requestCallCount += 1
1214
targetType = target
13-
if isError { throw MoneyMongError.appError(.default, errorMessage: "error case") }
15+
if isError { throw MoneyMongError.appError(.default) }
1416
return returnValue as! DTO
1517
}
1618

17-
public func request(target: any Core.TargetType) async throws {
19+
public func request(target: any TargetType) async throws {
1820
requestCallCount += 1
1921
targetType = target
20-
if isError { throw MoneyMongError.appError(.default, errorMessage: "error case") }
22+
if isError { throw MoneyMongError.appError(.default) }
2123
}
2224
}

Projects/Core/Repository/Sources/APIs/SignAPI/Repository/SignRepository.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public struct SignRepository: SignRepositoryInterface {
3333
do {
3434
return try await kakaoAuthManager.sign()
3535
} catch {
36-
throw MoneyMongError.unknown(error.localizedDescription)
36+
throw MoneyMongError.default(error.localizedDescription)
3737
}
3838
}
3939

4040
public func appleSign() async throws -> AppleAuthInfo {
4141
do {
4242
return try await appleAuthManager.sign()
4343
} catch {
44-
throw MoneyMongError.unknown(error.localizedDescription)
44+
throw MoneyMongError.default(error.localizedDescription)
4545
}
4646
}
4747

Projects/Domain/Agency/Sources/DeleteAgencyUseCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public struct DeleteAgencyUseCase: DeleteAgencyUseCaseInterface {
2424
widgetRefreshController.refresh()
2525
}
2626
guard let id else {
27-
throw MoneyMongError.appError(.default, errorMessage: "소속을 삭제할 수 없습니다\n잠시 후 다시 시도해 주세요")
27+
throw MoneyMongError.default("소속을 삭제할 수 없습니다\n잠시 후 다시 시도해 주세요")
2828
}
2929
try await agencyRepo.deleteAgency(id: id)
3030
let newAgency = try await agencyRepo.fetchMyAgency().first

Projects/Domain/Auth/Testing/MockAutoSignUseCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ public struct MockAutoSignUseCase: AutoSignUseCaseInterface {
44
public init() {}
55

66
public func execute() async throws {
7-
throw MoneyMongError.appError(.default, errorMessage: "")
7+
throw MoneyMongError.appError(.default)
88
}
99
}

Projects/Domain/BaseDomain/Sources/SocialLogin/Apple/AppleAuthManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extension AppleAuthManager: ASAuthorizationControllerDelegate {
4444
let name = appIDCredntial.fullName
4545
else {
4646
continuation?
47-
.resume(throwing: MoneyMongError.unknown("유저 정보를 가져오지 못했습니다."))
47+
.resume(throwing: MoneyMongError.default("유저 정보를 가져오지 못했습니다."))
4848
return
4949
}
5050
guard let familyName = name.familyName,
@@ -75,6 +75,6 @@ extension AppleAuthManager: ASAuthorizationControllerDelegate {
7575
return
7676
}
7777
continuation?
78-
.resume(throwing: MoneyMongError.unknown(error.localizedDescription))
78+
.resume(throwing: MoneyMongError.default(error.localizedDescription))
7979
}
8080
}

Projects/Domain/BaseDomain/Sources/SocialLogin/Kakao/KakaoAuthManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension KakaoAuthManager {
4343
if let kakaoError = error as? SdkError {
4444
let reason = kakaoError.getClientError().reason
4545
if reason == .Cancelled { return }
46-
continuation.resume(throwing: MoneyMongError.unknown(kakaoError.localizedDescription))
46+
continuation.resume(throwing: MoneyMongError.default(kakaoError.localizedDescription))
4747
}
4848
if let accessToken = oauthToken?.accessToken {
4949
continuation.resume(returning: KakaoAuthInfo(accessToken: accessToken))
@@ -56,7 +56,7 @@ extension KakaoAuthManager {
5656
if let kakaoError = error as? SdkError {
5757
let reason = kakaoError.getClientError().reason
5858
if reason == .Cancelled { return }
59-
continuation.resume(throwing: MoneyMongError.unknown(kakaoError.localizedDescription))
59+
continuation.resume(throwing: MoneyMongError.default(kakaoError.localizedDescription))
6060
}
6161
if let accessToken = oauthToken?.accessToken {
6262
continuation.resume(returning: KakaoAuthInfo(accessToken: accessToken))

Projects/Feature/Agency/Sources/Scene/JoinAgency/JoinAgencyReactor.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ final class JoinAgencyReactor: Reactor {
8585
newState.snackBarMessage = "잘못된 초대코드입니다"
8686
}
8787

88-
case let .joinAgencyResponse(.failure(value)):
89-
newState.errorMessage = value.errorDescription
88+
case let .joinAgencyResponse(.failure(error)):
89+
if error == MoneyMongError.appError(.invitation_001) ||
90+
error == MoneyMongError.appError(.invitation_002) ||
91+
error == MoneyMongError.appError(.invitation_003) {
92+
newState.snackBarMessage = "잘못된 초대코드입니다"
93+
} else {
94+
newState.errorMessage = error.errorDescription
95+
}
9096
}
9197
return newState
9298
}

Projects/Feature/Ledger/Sources/Scene/Ledger/Creaters/Manual/ManualCreater/CreateManualLedgerReactor.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ final class CreateManualLedgerReactor: Reactor {
151151
let imageURL: ImageInfo
152152
guard let index = currentState.content.documentImages.firstIndex(where: {
153153
$0.id == image.id
154-
}) else { throw MoneyMongError.appError(.default, errorMessage: "이미지 삭제가 정상적으로 이뤄지지 않았습니다") }
154+
}) else { throw MoneyMongError.default("이미지 삭제가 정상적으로 이뤄지지 않았습니다") }
155155
imageURL = currentState.content.documentImages[index]
156156
try await deleteImageUseCase.execute(imageURL)
157157
return index
@@ -265,14 +265,14 @@ private extension CreateManualLedgerReactor {
265265
func requestCreateLedgerRecord() -> Observable<Mutation> {
266266
return .task {
267267
guard let amount = Int(currentState.content.amount.filter { $0.isNumber }) else {
268-
throw MoneyMongError.appError(.default, errorMessage: "금액을 확인해 주세요")
268+
throw MoneyMongError.default("금액을 확인해 주세요")
269269
}
270270
guard let date = formatter.mergeWithISO8601(
271271
date: currentState.content.date,
272272
time: currentState.content.time != "" ? currentState.content.time : formatter.convertToTime(date: .now)
273273
)
274274
else {
275-
throw MoneyMongError.appError(.default, errorMessage: "날짜 및 시간을 확인해 주세요")
275+
throw MoneyMongError.default("날짜 및 시간을 확인해 주세요")
276276
}
277277
let memo = currentState.content.memo.isEmpty ? "내용없음" : currentState.content.memo
278278
return try await createLedgerUseCase.execute(
@@ -301,7 +301,7 @@ private extension CreateManualLedgerReactor {
301301
func uploadImage(image: ImageData) -> Observable<Mutation> {
302302
return .task {
303303
guard let resizeImateData = UIImage(data: image.data)?.jpegData(compressionQuality: 0.027) else {
304-
throw MoneyMongError.appError(.default, errorMessage: "첨부 이미지를 확인해 주세요")
304+
throw MoneyMongError.default("첨부 이미지를 확인해 주세요")
305305
}
306306
var entity = try await uploadImageUseCase.execute(imageData: resizeImateData)
307307
entity.id = image.id

Projects/Feature/Sign/Sources/Scene/Splash/SplashVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ final class SplashVC: BaseVC, View {
5555
.observe(on: MainScheduler.instance)
5656
.filter { $0 }
5757
.bind(with: self) { owner, value in
58-
owner.coordinator?.alert(title: "안정적인 머니몽 사용을 위해\n최신 버전으로 업데이트가 필요해요!") {
58+
owner.coordinator?.alert(title: "최적의 사용 환경을 위해\n머니몽 업데이트가 필요해요") {
5959
if let url = URL(string: "itms-apps://itunes.apple.com/app/id6503661220"),
6060
UIApplication.shared.canOpenURL(url)
6161
{

0 commit comments

Comments
 (0)