From d33d07dbf26d323df7c60e2a37f9373cc3cf99d0 Mon Sep 17 00:00:00 2001 From: minaje0917 Date: Wed, 22 Feb 2023 14:53:31 +0900 Subject: [PATCH 1/4] =?UTF-8?q?:zap:=20API=EC=97=90=20=EB=A7=9E=EA=B2=8C?= =?UTF-8?q?=20Error=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .package.resolved | 22 +++++++++---------- .../Data/DataSource/Remote/API/ImageAPI.swift | 8 ++++++- .../Data/DataSource/Remote/API/UserAPI.swift | 22 +++++++++++++++++-- Service/Sources/Domain/Error/GCMSError.swift | 7 ++++++ 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/.package.resolved b/.package.resolved index 0d02827c..3f90374f 100644 --- a/.package.resolved +++ b/.package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git", "state" : { - "revision" : "583de9bd60f66b40e78d08599cc92036c2e7e4e1", - "version" : "0.20220203.2" + "revision" : "d302de612e3d57c6f4afaf087da18fba8eac72a7", + "version" : "0.20220203.1" } }, { @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/boringssl-SwiftPM.git", "state" : { - "revision" : "dd3eda2b05a3f459fc3073695ad1b28659066eab", - "version" : "0.9.1" + "revision" : "79db6516894a932d0ddaff3b05b9da1e4f6c4069", + "version" : "0.9.0" } }, { @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/grpc/grpc-ios.git", "state" : { - "revision" : "8440b914756e0d26d4f4d054a1c1581daedfc5b6", - "version" : "1.44.3-grpc" + "revision" : "2af4f6e9c2b18beae228f50b1198c641be859d2b", + "version" : "1.44.2-grpc" } }, { @@ -104,14 +104,14 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/google/promises.git", "state" : { - "revision" : "3e4e743631e86c8c70dbc6efdc7beaa6e90fd3bb", - "version" : "2.1.1" + "revision" : "46c1e6b5ac09d8f82c991061c659f67e573d425d", + "version" : "2.1.0" } }, { "identity" : "realm-core", "kind" : "remoteSourceControl", - "location" : "https://github.com/realm/realm-core.git", + "location" : "https://github.com/realm/realm-core", "state" : { "revision" : "b77443ca7fa25407869ca537bf3ae912b1427bff", "version" : "12.13.0" @@ -131,8 +131,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "ab3a58b7209a17d781c0d1dbb3e1ff3da306bae8", - "version" : "1.20.3" + "revision" : "e1499bc69b9040b29184f7f2996f7bab467c1639", + "version" : "1.19.0" } } ], diff --git a/Service/Sources/Data/DataSource/Remote/API/ImageAPI.swift b/Service/Sources/Data/DataSource/Remote/API/ImageAPI.swift index 58d6f2e5..4ff8b3f4 100644 --- a/Service/Sources/Data/DataSource/Remote/API/ImageAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/ImageAPI.swift @@ -50,6 +50,12 @@ extension ImageAPI: GCMSAPI { } var errorMapper: [Int: Error]? { - return .none + switch self { + case .uploadImages: + return[ + 400: GCMSError.overFourPhoto, + 500: GCMSError.photoUploadFailed + ] + } } } diff --git a/Service/Sources/Data/DataSource/Remote/API/UserAPI.swift b/Service/Sources/Data/DataSource/Remote/API/UserAPI.swift index 46ecf7ce..0a789cf0 100644 --- a/Service/Sources/Data/DataSource/Remote/API/UserAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/UserAPI.swift @@ -66,8 +66,26 @@ extension UserAPI: GCMSAPI { var errorMapper: [Int: Error]? { switch self { - case .myProfile, .editProfile, .search, .miniProfile: - return [:] + case .myProfile, .miniProfile: + return [ + 401: GCMSError.unauthorized, + 404: GCMSError.notFoundUser, + 500: GCMSError.serverError + ] + + case .editProfile: + return [ + 400: GCMSError.invalidInput, + 401: GCMSError.unauthorized, + 404: GCMSError.notFoundUser, + 500: GCMSError.serverError + ] + + case .search: + return [ + 401: GCMSError.unauthorized, + 500: GCMSError.serverError + ] case .withdrawal: return [ diff --git a/Service/Sources/Domain/Error/GCMSError.swift b/Service/Sources/Domain/Error/GCMSError.swift index e248a108..4271b144 100644 --- a/Service/Sources/Domain/Error/GCMSError.swift +++ b/Service/Sources/Domain/Error/GCMSError.swift @@ -10,6 +10,7 @@ public enum GCMSError: Error { case invalidInput case noMebmerClub case failedAppleLogin + case overFourPhoto // MARK: - 401 case unauthorized @@ -45,6 +46,7 @@ public enum GCMSError: Error { // MARK: - 500 case serverError + case photoUploadFailed } extension GCMSError: LocalizedError { @@ -58,6 +60,8 @@ extension GCMSError: LocalizedError { return "인터넷 연결이 원활하지 않습니다" case .failedAppleLogin: return "애플 로그인을 실패 했습니다\n 잠시 후 다시 시도 해주세요" + case .overFourPhoto: + return "사진은 4개 이상 등록할 수 없습니다." // MARK: - 403 case .notGSMAccount: return "*@gsm.hs.kr 계정이 아닙니다" @@ -86,6 +90,9 @@ extension GCMSError: LocalizedError { return "이미 어떤 동아리에 소속 또는 신청되어있습니다" case .appliedToAnotherClubOrBelongClub: return "이미 어떤 동아리에 소속 또는 신청했습니다" + // MARK: - 500 + case .photoUploadFailed: + return "사진 업로드에 실패했습니다." } } } From b78706a8bc825076f024ee6aae9c8e556408ad5b Mon Sep 17 00:00:00 2001 From: minaje0917 Date: Wed, 22 Feb 2023 15:01:32 +0900 Subject: [PATCH 2/4] =?UTF-8?q?:zap:=20API=EC=97=90=20=EB=A7=9E=EA=B2=8C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/DataSource/Remote/API/AuthAPI.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Service/Sources/Data/DataSource/Remote/API/AuthAPI.swift b/Service/Sources/Data/DataSource/Remote/API/AuthAPI.swift index f94012ec..78c74301 100644 --- a/Service/Sources/Data/DataSource/Remote/API/AuthAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/AuthAPI.swift @@ -55,8 +55,23 @@ extension AuthAPI: GCMSAPI { } var errorMapper: [Int: Error]? { switch self { - case .login, .refresh, .logout: - return [:] + case .login: + return [ + 500: GCMSError.serverError + ] + + case .refresh: + return [ + 404: GCMSError.notFoundUser, + 500: GCMSError.serverError + ] + + case .logout: + return [ + 401: GCMSError.unauthorized, + 404: GCMSError.notFoundUser, + 500: GCMSError.serverError + ] } } From 63456bbc7be9a63d72d0f41c51c6fac0f9ff7388 Mon Sep 17 00:00:00 2001 From: minaje0917 Date: Wed, 22 Feb 2023 21:11:36 +0900 Subject: [PATCH 3/4] =?UTF-8?q?:zap:=20API=EC=97=90=20=EB=A7=9E=EA=B2=8C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Remote/API/ClubApplicantAPI.swift | 6 +++--- .../DataSource/Remote/API/ClubMemberAPI.swift | 2 +- .../Domain/Error/ClubApplicantError.swift | 18 +++++++++--------- .../Sources/Domain/Error/ClubMemberError.swift | 7 ++++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Service/Sources/Data/DataSource/Remote/API/ClubApplicantAPI.swift b/Service/Sources/Data/DataSource/Remote/API/ClubApplicantAPI.swift index d28c60fb..d88bbf60 100644 --- a/Service/Sources/Data/DataSource/Remote/API/ClubApplicantAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/ClubApplicantAPI.swift @@ -72,7 +72,7 @@ extension ClubApplicantAPI: GCMSAPI { case .apply: return[ 401: ClubApplicantError.unauthorized, - 403: ClubApplicantError.alreadyClubMember, + 403: ClubApplicantError.alreadyClubMemberOrSameTypeClub, 404: ClubApplicantError.notFoundClub, 500: ClubApplicantError.serverError ] @@ -89,7 +89,7 @@ extension ClubApplicantAPI: GCMSAPI { 400: ClubApplicantError.bodyIsNull, 401: ClubApplicantError.unauthorized, 403: ClubApplicantError.notClubHead, - 404: ClubApplicantError.notFoundAcceptUser, + 404: ClubApplicantError.notFoundAcceptUserOrClub, 500: ClubApplicantError.serverError ] @@ -98,7 +98,7 @@ extension ClubApplicantAPI: GCMSAPI { 400: ClubApplicantError.bodyIsNull, 401: ClubApplicantError.unauthorized, 403: ClubApplicantError.notClubHead, - 404: ClubApplicantError.notFoundRejectUser, + 404: ClubApplicantError.notFoundRejectUserOrClub, 500: ClubApplicantError.serverError ] } diff --git a/Service/Sources/Data/DataSource/Remote/API/ClubMemberAPI.swift b/Service/Sources/Data/DataSource/Remote/API/ClubMemberAPI.swift index 30486fb9..118ff155 100644 --- a/Service/Sources/Data/DataSource/Remote/API/ClubMemberAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/ClubMemberAPI.swift @@ -71,7 +71,7 @@ extension ClubMemberAPI: GCMSAPI { 400: ClubMemberError.kickMyself, 401: ClubMemberError.unauthorized, 403: ClubMemberError.notClubHead, - 404: ClubMemberError.notFoundClub, + 404: ClubMemberError.notFoundClubOrKickUser, 500: ClubMemberError.serverError ] diff --git a/Service/Sources/Domain/Error/ClubApplicantError.swift b/Service/Sources/Domain/Error/ClubApplicantError.swift index 6c93df98..2386c8f1 100644 --- a/Service/Sources/Domain/Error/ClubApplicantError.swift +++ b/Service/Sources/Domain/Error/ClubApplicantError.swift @@ -11,13 +11,13 @@ public enum ClubApplicantError: Error { case unauthorized // MARK: - 403 - case alreadyClubMember + case alreadyClubMemberOrSameTypeClub case notClubHead // MARK: - 404 case notFoundClub - case notFoundAcceptUser - case notFoundRejectUser + case notFoundAcceptUserOrClub + case notFoundRejectUserOrClub // MARK: - 500 case serverError @@ -37,8 +37,8 @@ extension ClubApplicantError: LocalizedError { case .unauthorized, .serverError: return "알수없는 에러가 발생했습니다. 잠시 후 다시 시도해 주세요." - case .alreadyClubMember: - return "이미 같은 동아리 소속입니다." + case .alreadyClubMemberOrSameTypeClub: + return "이미 같은 동아리 소속이거나 같은 타입의 동아리를 이미 신청했습니다." case .notClubHead: return "부장이 아니면 사용할 수 없습니다" @@ -46,11 +46,11 @@ extension ClubApplicantError: LocalizedError { case .notFoundClub: return "동아리를 찾을 수 없습니다." - case .notFoundAcceptUser: - return "수락하려는 유저를 찾을 수 없습니다." + case .notFoundAcceptUserOrClub: + return "수락하려는 유저를 찾을 수 없거나 동아리를 찾을 수 없습니다." - case .notFoundRejectUser: - return "거절하려는 유저를 찾을 수 없습니다." + case .notFoundRejectUserOrClub: + return "거절하려는 유저를 찾을 수 없거나 동아리를 찾을 수 없습니다." } } } diff --git a/Service/Sources/Domain/Error/ClubMemberError.swift b/Service/Sources/Domain/Error/ClubMemberError.swift index 11e1775a..20c52bb3 100644 --- a/Service/Sources/Domain/Error/ClubMemberError.swift +++ b/Service/Sources/Domain/Error/ClubMemberError.swift @@ -17,6 +17,7 @@ public enum ClubMemberError: Error { // MARK: - 404 case notFoundClub case notFoundKickUser + case notFoundClubOrKickUser // MARK: - 500 case serverError @@ -47,9 +48,9 @@ extension ClubMemberError: LocalizedError { // MARK: - 404 case .notFoundClub: return "동아리를 찾을 수 없습니다" - - case .notFoundKickUser: - return "방출하려는 유저를 찾을 수 없습니다" + + case .notFoundClubOrKickUser + return "동아리를 찾을 수 없거나 방출하려는 유저를 찾을 수 없습니다." } } } From cff382f03079cf98aeb95fb85b301fb2d7678443 Mon Sep 17 00:00:00 2001 From: baegteun Date: Sat, 25 Feb 2023 13:20:52 +0900 Subject: [PATCH 4/4] =?UTF-8?q?:goal=5Fnet:=20::=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=ED=91=9C=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/DataSource/Remote/API/AuthAPI.swift | 19 ++++-- .../Data/DataSource/Remote/API/ClubAPI.swift | 65 ++++++++++--------- .../Remote/API/ClubApplicantAPI.swift | 53 ++++++++------- .../DataSource/Remote/API/ClubMemberAPI.swift | 31 ++++----- .../Data/DataSource/Remote/API/GCMSAPI.swift | 3 +- .../Data/DataSource/Remote/API/ImageAPI.swift | 7 +- .../Data/DataSource/Remote/API/UserAPI.swift | 25 +++---- .../Remote/DataSource/BaseRemote.swift | 8 ++- .../Domain/Error/ClubMemberError.swift | 7 +- .../Auth/OnBoarding/OnBoardingReactor.swift | 2 +- .../Main/ClubMember/ClubMemberReactor.swift | 14 ++-- .../Main/DetailClub/DetailClubReactor.swift | 14 ++-- .../Scene/Main/MyPage/MyPageReactor.swift | 2 +- .../Scene/Main/MyPage/MyPageVC.swift | 2 +- .../Scene/Main/NewClub/NewClubReactor.swift | 4 +- .../Scene/Main/Update/UpdateClubReactor.swift | 4 +- .../Utils/Extensions/Swift/ErrorExt.swift | 8 --- 17 files changed, 143 insertions(+), 125 deletions(-) delete mode 100644 iOS/Sources/Presentation/Utils/Extensions/Swift/ErrorExt.swift diff --git a/Service/Sources/Data/DataSource/Remote/API/AuthAPI.swift b/Service/Sources/Data/DataSource/Remote/API/AuthAPI.swift index 78c74301..4526fb5b 100644 --- a/Service/Sources/Data/DataSource/Remote/API/AuthAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/AuthAPI.swift @@ -7,6 +7,8 @@ enum AuthAPI { } extension AuthAPI: GCMSAPI { + typealias ErrorType = GCMSError + var domain: GCMSDomain { return .auth } @@ -30,6 +32,7 @@ extension AuthAPI: GCMSAPI { return .delete } } + var task: Task { switch self { case let .login(req): @@ -41,6 +44,7 @@ extension AuthAPI: GCMSAPI { return .requestPlain } } + var jwtTokenType: JWTTokenType? { switch self { case .refresh: @@ -53,24 +57,25 @@ extension AuthAPI: GCMSAPI { return JWTTokenType.none } } - var errorMapper: [Int: Error]? { + + var errorMapper: [Int: GCMSError]? { switch self { case .login: return [ - 500: GCMSError.serverError + 500: .serverError ] case .refresh: return [ - 404: GCMSError.notFoundUser, - 500: GCMSError.serverError + 404: .notFoundUser, + 500: .serverError ] case .logout: return [ - 401: GCMSError.unauthorized, - 404: GCMSError.notFoundUser, - 500: GCMSError.serverError + 401: .unauthorized, + 404: .notFoundUser, + 500: .serverError ] } } diff --git a/Service/Sources/Data/DataSource/Remote/API/ClubAPI.swift b/Service/Sources/Data/DataSource/Remote/API/ClubAPI.swift index e3dd1c1c..08628db5 100644 --- a/Service/Sources/Data/DataSource/Remote/API/ClubAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/ClubAPI.swift @@ -76,69 +76,70 @@ extension ClubAPI: GCMSAPI { } } - var errorMapper: [Int: Error]? { + typealias ErrorType = GCMSError + var errorMapper: [Int: GCMSError]? { switch self { case .clubList: return [ - 400: GCMSError.invalidInput, - 401: GCMSError.unauthorized, - 500: GCMSError.serverError + 400: .invalidInput, + 401: .unauthorized, + 500: .serverError ] case .clubDetail: return [ - 401: GCMSError.unauthorized, - 404: GCMSError.notFoundUserOrNotFoundClub, - 500: GCMSError.serverError + 401: .unauthorized, + 404: .notFoundUserOrNotFoundClub, + 500: .serverError ] case .createNewClub: return [ - 400: GCMSError.invalidInput, - 401: GCMSError.unauthorized, - 409: GCMSError.alreadyExistClub, - 500: GCMSError.serverError + 400: .invalidInput, + 401: .unauthorized, + 409: .alreadyExistClub, + 500: .serverError ] case .updateClub: return [ - 400: GCMSError.invalidInput, - 401: GCMSError.unauthorized, - 403: GCMSError.notClubHead, - 404: GCMSError.notFoundClub, - 500: GCMSError.serverError + 400: .invalidInput, + 401: .unauthorized, + 403: .notClubHead, + 404: .notFoundClub, + 500: .serverError ] case .deleteClub: return [ - 401: GCMSError.unauthorized, - 403: GCMSError.notClubHead, - 404: GCMSError.notFoundClub, - 500: GCMSError.serverError + 401: .unauthorized, + 403: .notClubHead, + 404: .notFoundClub, + 500: .serverError ] case .clubOpen: return [ - 401: GCMSError.unauthorized, - 403: GCMSError.notClubHead, - 404: GCMSError.notFoundClub, - 500: GCMSError.serverError + 401: .unauthorized, + 403: .notClubHead, + 404: .notFoundClub, + 500: .serverError ] case .clubClose: return [ - 401: GCMSError.unauthorized, - 403: GCMSError.notClubHead, - 404: GCMSError.notFoundClub, - 500: GCMSError.serverError + 401: .unauthorized, + 403: .notClubHead, + 404: .notFoundClub, + 500: .serverError ] case .exitClub: return [ - 400: GCMSError.noMebmerClub, - 401: GCMSError.unauthorized, - 404: GCMSError.notFoundClub, - 500: GCMSError.serverError + 400: .noMebmerClub, + 401: .unauthorized, + 404: .notFoundClub, + 500: .serverError ] } } diff --git a/Service/Sources/Data/DataSource/Remote/API/ClubApplicantAPI.swift b/Service/Sources/Data/DataSource/Remote/API/ClubApplicantAPI.swift index d88bbf60..7d08a0d7 100644 --- a/Service/Sources/Data/DataSource/Remote/API/ClubApplicantAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/ClubApplicantAPI.swift @@ -17,8 +17,14 @@ extension ClubApplicantAPI: GCMSAPI { var urlPath: String { switch self { - case let .applicantList(clubID), let .userAccept(clubID, _), let .userReject(clubID, _), let .apply(clubID), let .cancel(clubID): + case let .applicantList(clubID), let .apply(clubID), let .cancel(clubID): return "/\(clubID)" + + case let .userAccept(clubID, _): + return "/\(clubID)/accept" + + case let .userReject(clubID, _): + return "/\(clubID)/reject" } } @@ -59,47 +65,48 @@ extension ClubApplicantAPI: GCMSAPI { } } - var errorMapper: [Int: Error]? { + typealias ErrorType = ClubApplicantError + var errorMapper: [Int: ClubApplicantError]? { switch self { case .applicantList: return[ - 400: ClubApplicantError.notClubMember, - 401: ClubApplicantError.unauthorized, - 404: ClubApplicantError.notFoundClub, - 500: ClubApplicantError.serverError + 400: .notClubMember, + 401: .unauthorized, + 404: .notFoundClub, + 500: .serverError ] case .apply: return[ - 401: ClubApplicantError.unauthorized, - 403: ClubApplicantError.alreadyClubMemberOrSameTypeClub, - 404: ClubApplicantError.notFoundClub, - 500: ClubApplicantError.serverError + 401: .unauthorized, + 403: .alreadyClubMemberOrSameTypeClub, + 404: .notFoundClub, + 500: .serverError ] case .cancel: return[ - 401: ClubApplicantError.unauthorized, - 404: ClubApplicantError.notFoundClub, - 500: ClubApplicantError.serverError + 401: .unauthorized, + 404: .notFoundClub, + 500: .serverError ] case .userAccept: return[ - 400: ClubApplicantError.bodyIsNull, - 401: ClubApplicantError.unauthorized, - 403: ClubApplicantError.notClubHead, - 404: ClubApplicantError.notFoundAcceptUserOrClub, - 500: ClubApplicantError.serverError + 400: .bodyIsNull, + 401: .unauthorized, + 403: .notClubHead, + 404: .notFoundAcceptUserOrClub, + 500: .serverError ] case .userReject: return[ - 400: ClubApplicantError.bodyIsNull, - 401: ClubApplicantError.unauthorized, - 403: ClubApplicantError.notClubHead, - 404: ClubApplicantError.notFoundRejectUserOrClub, - 500: ClubApplicantError.serverError + 400: .bodyIsNull, + 401: .unauthorized, + 403: .notClubHead, + 404: .notFoundRejectUserOrClub, + 500: .serverError ] } } diff --git a/Service/Sources/Data/DataSource/Remote/API/ClubMemberAPI.swift b/Service/Sources/Data/DataSource/Remote/API/ClubMemberAPI.swift index 118ff155..7f988433 100644 --- a/Service/Sources/Data/DataSource/Remote/API/ClubMemberAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/ClubMemberAPI.swift @@ -56,32 +56,33 @@ extension ClubMemberAPI: GCMSAPI { } } - var errorMapper: [Int: Error]? { + typealias ErrorType = ClubMemberError + var errorMapper: [Int: ClubMemberError]? { switch self { case .clubMember: return [ - 401: ClubMemberError.unauthorized, - 403: ClubMemberError.notClubMember, - 404: ClubMemberError.notFoundClub, - 500: ClubMemberError.serverError + 401: .unauthorized, + 403: .notClubMember, + 404: .notFoundClub, + 500: .serverError ] case .userKick: return [ - 400: ClubMemberError.kickMyself, - 401: ClubMemberError.unauthorized, - 403: ClubMemberError.notClubHead, - 404: ClubMemberError.notFoundClubOrKickUser, - 500: ClubMemberError.serverError + 400: .kickMyself, + 401: .unauthorized, + 403: .notClubHead, + 404: .notFoundClubOrKickUser, + 500: .serverError ] case .delegation: return [ - 400: ClubMemberError.delegationMyself, - 401: ClubMemberError.unauthorized, - 403: ClubMemberError.notClubHead, - 404: ClubMemberError.notFoundClub, - 500: ClubMemberError.serverError + 400: .delegationMyself, + 401: .unauthorized, + 403: .notClubHead, + 404: .notFoundClub, + 500: .serverError ] } } diff --git a/Service/Sources/Data/DataSource/Remote/API/GCMSAPI.swift b/Service/Sources/Data/DataSource/Remote/API/GCMSAPI.swift index 22b087d7..fd883c17 100644 --- a/Service/Sources/Data/DataSource/Remote/API/GCMSAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/GCMSAPI.swift @@ -2,9 +2,10 @@ import Moya import Foundation protocol GCMSAPI: TargetType, JWTTokenAuthorizable { + associatedtype ErrorType: Error var domain: GCMSDomain { get } var urlPath: String { get } - var errorMapper: [Int: Error]? { get } + var errorMapper: [Int: ErrorType]? { get } } extension GCMSAPI { diff --git a/Service/Sources/Data/DataSource/Remote/API/ImageAPI.swift b/Service/Sources/Data/DataSource/Remote/API/ImageAPI.swift index 4ff8b3f4..c2971cdd 100644 --- a/Service/Sources/Data/DataSource/Remote/API/ImageAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/ImageAPI.swift @@ -49,12 +49,13 @@ extension ImageAPI: GCMSAPI { return ["Content-type": "multipart/form-data"] } - var errorMapper: [Int: Error]? { + typealias ErrorType = GCMSError + var errorMapper: [Int: GCMSError]? { switch self { case .uploadImages: return[ - 400: GCMSError.overFourPhoto, - 500: GCMSError.photoUploadFailed + 400: .overFourPhoto, + 500: .photoUploadFailed ] } } diff --git a/Service/Sources/Data/DataSource/Remote/API/UserAPI.swift b/Service/Sources/Data/DataSource/Remote/API/UserAPI.swift index 0a789cf0..129ef063 100644 --- a/Service/Sources/Data/DataSource/Remote/API/UserAPI.swift +++ b/Service/Sources/Data/DataSource/Remote/API/UserAPI.swift @@ -64,33 +64,34 @@ extension UserAPI: GCMSAPI { } } - var errorMapper: [Int: Error]? { + typealias ErrorType = GCMSError + var errorMapper: [Int: GCMSError]? { switch self { case .myProfile, .miniProfile: return [ - 401: GCMSError.unauthorized, - 404: GCMSError.notFoundUser, - 500: GCMSError.serverError + 401: .unauthorized, + 404: .notFoundUser, + 500: .serverError ] case .editProfile: return [ - 400: GCMSError.invalidInput, - 401: GCMSError.unauthorized, - 404: GCMSError.notFoundUser, - 500: GCMSError.serverError + 400: .invalidInput, + 401: .unauthorized, + 404: .notFoundUser, + 500: .serverError ] case .search: return [ - 401: GCMSError.unauthorized, - 500: GCMSError.serverError + 401: .unauthorized, + 500: .serverError ] case .withdrawal: return [ - 401: GCMSError.unauthorized, - 403: GCMSError.notExistUser + 401: .unauthorized, + 403: .notExistUser ] } } diff --git a/Service/Sources/Data/DataSource/Remote/DataSource/BaseRemote.swift b/Service/Sources/Data/DataSource/Remote/DataSource/BaseRemote.swift index 4494bcc2..1c4443f3 100644 --- a/Service/Sources/Data/DataSource/Remote/DataSource/BaseRemote.swift +++ b/Service/Sources/Data/DataSource/Remote/DataSource/BaseRemote.swift @@ -56,7 +56,13 @@ private extension BaseRemote { return self.reissueToken() .andThen(.error(TokenError.expired)) } - return .error(api.errorMapper?[code] ?? GCMSError.error(message: (try? (error as? MoyaError)?.response?.mapJSON() as? NSDictionary)?["message"] as? String ?? "", errorBody: [:])) + return .error( + api.errorMapper?[code] ?? + GCMSError.error( + message: (try? (error as? MoyaError)?.response?.mapJSON() as? NSDictionary)?["message"] as? String ?? "", + errorBody: [:] + ) + ) } } diff --git a/Service/Sources/Domain/Error/ClubMemberError.swift b/Service/Sources/Domain/Error/ClubMemberError.swift index 20c52bb3..9ea5a07a 100644 --- a/Service/Sources/Domain/Error/ClubMemberError.swift +++ b/Service/Sources/Domain/Error/ClubMemberError.swift @@ -49,8 +49,11 @@ extension ClubMemberError: LocalizedError { case .notFoundClub: return "동아리를 찾을 수 없습니다" - case .notFoundClubOrKickUser - return "동아리를 찾을 수 없거나 방출하려는 유저를 찾을 수 없습니다." + case .notFoundClubOrKickUser: + return "동아리를 찾을 수 없거나 방출하려는 유저를 찾을 수 없습니다" + + case .notFoundKickUser: + return "방출하려는 유저를 찾을 수 없습니다" } } } diff --git a/iOS/Sources/Presentation/Scene/Auth/OnBoarding/OnBoardingReactor.swift b/iOS/Sources/Presentation/Scene/Auth/OnBoarding/OnBoardingReactor.swift index 3220b836..d8bfaf15 100644 --- a/iOS/Sources/Presentation/Scene/Auth/OnBoarding/OnBoardingReactor.swift +++ b/iOS/Sources/Presentation/Scene/Auth/OnBoarding/OnBoardingReactor.swift @@ -77,7 +77,7 @@ private extension OnBoardingReactor { .subscribe(with: self) { owner, _ in owner.steps.accept(GCMSStep.clubListIsRequired) } onError: { owner, e in - owner.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription, action: [])) + owner.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription, action: [])) } .disposed(by: disposeBag) return .empty() diff --git a/iOS/Sources/Presentation/Scene/Main/ClubMember/ClubMemberReactor.swift b/iOS/Sources/Presentation/Scene/Main/ClubMember/ClubMemberReactor.swift index 5d170984..ae1a2efc 100644 --- a/iOS/Sources/Presentation/Scene/Main/ClubMember/ClubMemberReactor.swift +++ b/iOS/Sources/Presentation/Scene/Main/ClubMember/ClubMemberReactor.swift @@ -140,7 +140,7 @@ private extension ClubMemberReactor { .just(.appendUsers($0)) ]) } .catch { [weak self] e in - self?.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription, action: [])) + self?.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription, action: [])) return .just(.setIsLoading(false)) } let applicant = fetchClubApplicantUseCase.execute(clubID: self.clubID) @@ -165,7 +165,7 @@ private extension ClubMemberReactor { self.action.onNext(.clubIsOpenedChange(false)) self.steps.accept(GCMSStep.alert(title: "성공", message: "동아리 신청이 마감되었습니다.", style: .alert, actions: [.init(title: "확인", style: .default)])) } onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) } .disposed(by: self.disposeBag) }), @@ -181,7 +181,7 @@ private extension ClubMemberReactor { self.action.onNext(.clubIsOpenedChange(true)) self.steps.accept(GCMSStep.alert(title: "성공", message: "동아리 신청이 열렸습니다.", style: .alert, actions: [.init(title: "확인", style: .default)])) } onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) } .disposed(by: self.disposeBag) }), @@ -200,7 +200,7 @@ private extension ClubMemberReactor { self.steps.accept(GCMSStep.popToRoot) self.action.onNext(.viewDidLoad) }, onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) }) .disposed(by: self.disposeBag) }), @@ -218,7 +218,7 @@ private extension ClubMemberReactor { self.steps.accept(GCMSStep.alert(title: "성공", message: "성공적으로 '\(user.name)'님을 추방했습니다", style: .alert, actions: [.init(title: "확인", style: .default)])) self.action.onNext(.viewDidLoad) }, onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) }) .disposed(by: self.disposeBag) }), @@ -236,7 +236,7 @@ private extension ClubMemberReactor { self.steps.accept(GCMSStep.alert(title: "성공", message: "성공적으로 '\(user.name)'님의 가입을 승인했습니다", style: .alert, actions: [.init(title: "확인", style: .default)])) self.action.onNext(.viewDidLoad) }, onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) }) .disposed(by: self.disposeBag) }), @@ -254,7 +254,7 @@ private extension ClubMemberReactor { self.steps.accept(GCMSStep.alert(title: "성공", message: "성공적으로 '\(user.name)'님의 가입을 거절했습니다", style: .alert, actions: [.init(title: "확인", style: .default)])) self.action.onNext(.viewDidLoad) }, onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) }) .disposed(by: self.disposeBag) }), diff --git a/iOS/Sources/Presentation/Scene/Main/DetailClub/DetailClubReactor.swift b/iOS/Sources/Presentation/Scene/Main/DetailClub/DetailClubReactor.swift index b10681c5..c11a2e36 100644 --- a/iOS/Sources/Presentation/Scene/Main/DetailClub/DetailClubReactor.swift +++ b/iOS/Sources/Presentation/Scene/Main/DetailClub/DetailClubReactor.swift @@ -113,7 +113,7 @@ private extension DetailClubReactor { .asObservable() .flatMap { Observable.from([Mutation.setClub($0), .setIsLoading(false)]) } .catch { [weak self] e in - self?.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription, action: [])) + self?.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription, action: [])) return .just(.setIsLoading(false)) } @@ -176,7 +176,7 @@ private extension DetailClubReactor { .subscribe(onNext: { _ in self.steps.accept(GCMSStep.popToRoot) }, onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "알 수 없는 오류가 일어났습니다.", message: e.asGCMSError?.errorDescription, action: [ + self.steps.accept(GCMSStep.failureAlert(title: "알 수 없는 오류가 일어났습니다.", message: e.localizedDescription, action: [ .init(title: "확인", style: .default) ])) }) @@ -194,7 +194,7 @@ private extension DetailClubReactor { .subscribe(onNext: { _ in self.steps.accept(GCMSStep.popToRoot) }, onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "알 수 없는 오류가 일어났습니다.", message: e.asGCMSError?.errorDescription, action: [ + self.steps.accept(GCMSStep.failureAlert(title: "알 수 없는 오류가 일어났습니다.", message: e.localizedDescription, action: [ .init(title: "확인", style: .default) ])) }) @@ -213,7 +213,7 @@ private extension DetailClubReactor { self.steps.accept(GCMSStep.alert(title: "성공", message: "동아리 신청이 마감되었습니다.", style: .alert, actions: [.init(title: "확인", style: .default)])) self.action.onNext(.updateClub(self.currentState.clubDetail?.copyForChange(isOpen: false))) } onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) } .disposed(by: self.disposeBag) }), @@ -231,7 +231,7 @@ private extension DetailClubReactor { self.steps.accept(GCMSStep.alert(title: "성공", message: "동아리 신청이 열렸습니다.", style: .alert, actions: [.init(title: "확인", style: .default)])) self.action.onNext(.updateClub(self.currentState.clubDetail?.copyForChange(isOpen: true))) } onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) } .disposed(by: self.disposeBag) }), @@ -253,7 +253,7 @@ private extension DetailClubReactor { self.steps.accept(GCMSStep.alert(title: "성공", message: "동아리 신청이 성공하였습니다.", style: .alert, actions: [.init(title: "확인", style: .default)])) self.action.onNext(.updateClub(self.currentState.clubDetail?.copyForChange(isApplied: true))) } onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) } .disposed(by: self.disposeBag) }), @@ -272,7 +272,7 @@ private extension DetailClubReactor { self.steps.accept(GCMSStep.alert(title: "성공", message: "동아리 신청이 취소되었습니다.", style: .alert, actions: [.init(title: "확인", style: .default)])) self.action.onNext(.updateClub(self.currentState.clubDetail?.copyForChange(isApplied: false))) } onError: { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) } .disposed(by: self.disposeBag) }), diff --git a/iOS/Sources/Presentation/Scene/Main/MyPage/MyPageReactor.swift b/iOS/Sources/Presentation/Scene/Main/MyPage/MyPageReactor.swift index 49ad2ef4..cca128e0 100644 --- a/iOS/Sources/Presentation/Scene/Main/MyPage/MyPageReactor.swift +++ b/iOS/Sources/Presentation/Scene/Main/MyPage/MyPageReactor.swift @@ -132,7 +132,7 @@ private extension MyPageReactor { .catchAndReturn(.setIsLoading(false)) } .catch { [weak self] e in - self?.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription, action: [])) + self?.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription, action: [])) return .just(.setIsLoading(false)) } return .concat([start, task]) diff --git a/iOS/Sources/Presentation/Scene/Main/MyPage/MyPageVC.swift b/iOS/Sources/Presentation/Scene/Main/MyPage/MyPageVC.swift index 83cb03e6..e9e73ec0 100644 --- a/iOS/Sources/Presentation/Scene/Main/MyPage/MyPageVC.swift +++ b/iOS/Sources/Presentation/Scene/Main/MyPage/MyPageVC.swift @@ -221,7 +221,7 @@ extension MyPageVC: PHPickerViewControllerDelegate { item?.loadDataRepresentation(forTypeIdentifier: "public.image", completionHandler: { [weak self] data, err in if let err = err { - print(err.asGCMSError?.errorDescription ?? "") + print(err.localizedDescription ?? "") return } if let data = data { diff --git a/iOS/Sources/Presentation/Scene/Main/NewClub/NewClubReactor.swift b/iOS/Sources/Presentation/Scene/Main/NewClub/NewClubReactor.swift index 66ba4f3b..a8c20922 100644 --- a/iOS/Sources/Presentation/Scene/Main/NewClub/NewClubReactor.swift +++ b/iOS/Sources/Presentation/Scene/Main/NewClub/NewClubReactor.swift @@ -252,12 +252,12 @@ private extension NewClubReactor { }) .andThen(Observable.just(Mutation.setIsLoading(false))) .catch { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) return .just(.setIsLoading(false)) } } .catch { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) return .just(.setIsLoading(false)) } return .concat([start, task]) diff --git a/iOS/Sources/Presentation/Scene/Main/Update/UpdateClubReactor.swift b/iOS/Sources/Presentation/Scene/Main/Update/UpdateClubReactor.swift index 20db7694..f8c38186 100644 --- a/iOS/Sources/Presentation/Scene/Main/Update/UpdateClubReactor.swift +++ b/iOS/Sources/Presentation/Scene/Main/Update/UpdateClubReactor.swift @@ -299,12 +299,12 @@ private extension UpdateClubReactor { }) .andThen(Observable.just(Mutation.setIsLoading(false))) .catch { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) return .just(.setIsLoading(false)) } } .catch { e in - self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.asGCMSError?.errorDescription)) + self.steps.accept(GCMSStep.failureAlert(title: "실패", message: e.localizedDescription)) return .just(.setIsLoading(false)) } return .concat([startLoadingObservable, updateObservable]) diff --git a/iOS/Sources/Presentation/Utils/Extensions/Swift/ErrorExt.swift b/iOS/Sources/Presentation/Utils/Extensions/Swift/ErrorExt.swift deleted file mode 100644 index 0cd205c3..00000000 --- a/iOS/Sources/Presentation/Utils/Extensions/Swift/ErrorExt.swift +++ /dev/null @@ -1,8 +0,0 @@ -import Foundation -import Service - -extension Error { - var asGCMSError: GCMSError? { - return self as? GCMSError - } -}