jdisho / Papr

🌁 An Unsplash app for iOS
Apache License 2.0
1.15k stars 149 forks source link

Add error handling to avoid crash if getting error reponse from loading image #103

Closed xingye closed 4 years ago

xingye commented 4 years ago

If any of the image requests get an error response, it will crash since binding error. Catch error and return an empty observable or a placeholder image to avoid the crash.

jdisho commented 4 years ago

Thanks for the contribution! How about we create a custom operator in the ObservableType extension like the following:

func orEmpty() -> Observable<Element> {
    return catchError { _ in
        return Observable.empty()
    }
}

and use this operator in all the similar case?

xingye commented 4 years ago

Thanks for your reply. I have applied the error handling using ObservableType extension for all the image view bindings. Could you please help to review it?