-
Notifications
You must be signed in to change notification settings - Fork 0
[Work 47] Firebase 초기 설정을 완료했습니다. #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d3cf1c3
CHORE: Firebase 프로젝트 연결
sangYuLv 8241990
CHORE: FirebaseAuth/Database/Firestore/Storage 패키지 추가
sangYuLv ff23119
CHORE: Firebase CLI 초기 설정 및 에뮬레이터 연결
sangYuLv 378f4ce
FEAT: Firebase 에러 처리 모델 추가
sangYuLv a6e1154
DOCS: JSON 파일의 주석 제거
sangYuLv f08a64e
DOCS: RTDB 에러 상수 설명 주석 추가
sangYuLv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "projects": { | ||
| "default": "whereareyou-16ea6" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 118 additions & 1 deletion
119
WhereAreYou/WhereAreYou.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // | ||
| // FirebaseErrorMapper.swift | ||
| // WhereAreYou | ||
| // | ||
| // Created by 이상유 on 2026-08-26. | ||
| // | ||
|
|
||
| import Foundation | ||
| import FirebaseAuth | ||
| import FirebaseFirestore | ||
| import FirebaseDatabase | ||
| import FirebaseStorage | ||
|
|
||
| /// Firebase NSError → AppError 변환기 | ||
| enum FirebaseErrorMapper { | ||
|
|
||
| static func map(_ error: Error) -> AppError { | ||
| let nsError = error as NSError | ||
|
|
||
| switch nsError.domain { | ||
| case AuthErrorDomain: | ||
| return mapAuth(nsError) | ||
| case FirestoreErrorDomain: | ||
| return mapFirestore(nsError) | ||
| case "com.firebase.database": | ||
| return mapDatabase(nsError) | ||
| case StorageErrorDomain: | ||
| return mapStorage(nsError) | ||
| default: | ||
| return mapGeneral(nsError) | ||
| } | ||
| } | ||
|
|
||
| private static func mapAuth(_ error: NSError) -> AppError { | ||
| guard let code = AuthErrorCode(rawValue: error.code) else { | ||
| return .unknown(error) | ||
| } | ||
| switch code { | ||
| case .networkError: | ||
| return .network | ||
| case .userNotFound, .userTokenExpired, .invalidUserToken: | ||
| return .notAuthenticated | ||
| case .emailAlreadyInUse: | ||
| return .alreadyExists | ||
| default: | ||
| return .unknown(error) | ||
| } | ||
| } | ||
|
|
||
| private static func mapFirestore(_ error: NSError) -> AppError { | ||
| switch FirestoreErrorCode.Code(rawValue: error.code) { | ||
| case .notFound: | ||
| return .notFound | ||
| case .permissionDenied, .unauthenticated: | ||
| return .permissionDenied | ||
| case .alreadyExists: | ||
| return .alreadyExists | ||
| case .unavailable: | ||
| return .network | ||
| default: | ||
| return .unknown(error) | ||
| } | ||
| } | ||
|
|
||
| private static func mapDatabase(_ error: NSError) -> AppError { | ||
| // Realtime Database SDK는 public error code enum을 제공하지 않음 | ||
| switch error.code { | ||
| case -4: // disconnected | ||
| return .network | ||
| case -3: // permission_denied | ||
| return .permissionDenied | ||
| default: | ||
| return .unknown(error) | ||
| } | ||
| } | ||
|
|
||
| private static func mapStorage(_ error: NSError) -> AppError { | ||
| switch StorageErrorCode(rawValue: error.code) { | ||
| case .objectNotFound: | ||
| return .notFound | ||
| case .unauthorized, .unauthenticated: | ||
| return .permissionDenied | ||
| case .quotaExceeded: | ||
| return .unknown(error) | ||
| case .retryLimitExceeded: | ||
| return .network | ||
| default: | ||
| return .unknown(error) | ||
| } | ||
| } | ||
|
|
||
| private static func mapGeneral(_ error: NSError) -> AppError { | ||
| if error.domain == NSURLErrorDomain { | ||
| return .network | ||
| } | ||
| return .unknown(error) | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.