Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions RocketCall/View/Mission/List/MissionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ extension MissionViewController {
try self.coreDataManager.deleteMissionEntity(of: mission.id)
self.initialLoadSubject.onNext(())
} catch {
self.showErrorAlert(error: .saveFailed)
if let coreDataError = error as? CoreDataManager.CoreDataError {
self.showErrorAlert(error: coreDataError)
} else {
self.showErrorAlert(error: .saveFailed)
}
Comment on lines +184 to +188
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

이 catch 블록에서 모든 오류 타입을 명시적으로 처리해야 합니다. 특정 오류 타입만 발생할 것이라고 간주하여 나머지 처리를 생략하거나 'dead code'로 취급하는 것은 Rx 스트림의 안정성을 해칠 수 있습니다. Rx 스트림에서는 예상치 못한 오류로 인해 스트림이 종료되는 것을 방지하기 위해 모든 오류를 처리해야 하며, 사용자에게는 일반적인 메시지 대신 실제 발생한 오류의 내용을 반영하는 구체적인 메시지를 제공해야 합니다.

catch {
    if let coreDataError = error as? CoreDataManager.CoreDataError {
        self.showErrorAlert(error: coreDataError)
    } else {
        self.showErrorAlert(message: error.localizedDescription)
    }
}
References
  1. In an Rx stream, use a do-catch block to handle all possible error types, not just expected ones, to prevent the stream from terminating unexpectedly.
  2. When displaying errors to the user, provide specific and meaningful messages based on the error type instead of a generic message.

}
})
.disposed(by: disposeBag)
Expand All @@ -201,7 +205,7 @@ extension MissionViewController {
case .customMission(let mission) = item else { return nil }

return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ in
let delete = UIAction(title: "삭제", image: UIImage(systemName: "trah.fill"), attributes: .destructive) { [weak self] _ in
let delete = UIAction(title: "삭제", image: UIImage(systemName: "trash.fill"), attributes: .destructive) { [weak self] _ in
self?.deleteMissionSubject.onNext(mission)
}
return UIMenu(title: "",children: [delete])
Expand Down
Loading