Skip to content
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

[no] 로그인 실패 시 alert가 뜨지 않는 이슈 해결 #146

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

seungwon-yoo
Copy link
Contributor

@seungwon-yoo seungwon-yoo commented Jul 17, 2023

작업내용

참고

  • 500번이 뜨면 APIError를 throw 할텐데 그렇지 않은 이유가 뭘까요.. 일단 분기 탄 곳에 alert 뜨게 했는데 원인을 찾아봐야할 것 같습니다.

@seungwon-yoo
Copy link
Contributor Author

seungwon-yoo commented Jul 17, 2023

이 쪽에서 error를 던져줘서 그렇 것 같기도 합니다. MoyaError일 것 같은데 재현이 안되네요.

func request(_ token: Base.Target, callbackQueue: DispatchQueue? = nil) -> Single<Response> {
        Single.create { [weak base] single in
            let cancellableToken = base?.request(token, callbackQueue: callbackQueue, progress: nil) { result in
                switch result {
                case let .success(response):
                    single(.success(response))
                case let .failure(error):
                    single(.failure(error))
                }
            }

            return Disposables.create {
                cancellableToken?.cancel()
            }
        }
    }

}
} else {
Log.error(error)
owner.showSinglePopUpAlert(message: "알 수 없는 오류가 발생했습니다.")
Copy link
Member

Choose a reason for hiding this comment

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

여기서 log만 찍어서 안보였던거 같습니다!

simpleErrorHandler
    .withUnretained(self)
    .observe(on: MainScheduler.instance)
    .subscribe(onNext: { owner, error in
        if error is APIError {
            let apiError = error as! APIError
            
            switch apiError {
            case .errorMessage(let message):
                owner.showSinglePopUpAlert(message: message)
            default:
                owner.showSinglePopUpAlert(message: "알 수 없는 오류가 발생했습니다.")
            }
        } else {
            owner.showSinglePopUpAlert(message: "알 수 없는 오류가 발생했습니다.")
        }
        Log.error(error)
    })
    .disposed(by: disposeBag)

SZVC에 simpleErrorHandler 라고 error가 errorMessage 인경우는 서버에서 전달해준 message 보여주고 이외에는 알 수 없는 오류 라고 alert 띄우는 relay 있습니다!

simpleErrorHandler 에 error 전달 해주는 방법으로 처리 해도 좋을거같아요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants