Following is my code for signing up
self.signedUp  = signUpButtonTap.withLatestFrom(userAndPassword).flatMapLatest{
            input ->  Observable<Response> in
            return  Observable.create { observer in
                let userData = Creator()
                userData?.username = input.0
                userData?.password = input.1
                provider.request(.signIn(userData!)).filter(statusCode: 200).subscribe{  event -> Void in
                    switch event {
                    case .next(let response):
                        observer.onNext(response)
                    case .error(let error):
                        let moyaError: MoyaError? = error as? MoyaError
                        let response: Response? = moyaError?.response
                        let statusCode: Int? = response?.statusCode
                        observer.onError(error)
                    default:
                        break
                    }
                }
                return Disposables.create()
            }
        }
Following is the binding in the View
 self.viewModel.signedUp.bind{response in
               self.displayPopUpForSuccessfulLogin()
            }
When there is a successful response its works fine.
But when the request times out or I get any other status code than 200, I get the following error "fatalError(lastMessage)" and the app crashes.
When I replace observer.onError(error) with observer.onNext(response) in the case .error it works for response codes other than 200 , but crashes again when the request times out.
I have gone through this link Handling Network error in combination with binding to tableView (Moya, RxSwift, RxCocoa)
Can anyone help me out with what is wrong. I am completely new to RxSwift . Any help will be appreciated. Thank you