Chapter 10 - An offline problem

hi crew!

the situation is when i launch the our planet app without internet. App crash in rxFatalError in RxCocoa.swift but i don’t know why and i don’t know how resolve it.

So thxs.

Hi @gil_escura, thanks for posting in the forums!

This happens because we are binding the results of the download directly to the categories variable. I’m no expert on RxSwift but you are unable to bind failure as this is undefined state so RxSwift will instead throw a fatalError (in debug) if an error occurs.

The real way to handle this depends on the use case however you’re probably going to want to catch the error and return something else somehow… In this particular case, you can do the following at the end of the CategoriesViewController.startDownload() function:


I’ve added the .catchErrorJustReturn([]) line that will instead of throwing an exception, it’ll continue with an empty array. While this stops a crash, it doesn’t help the user as there is no explanation as to what has happened but you can get creative here and add error handling with ease :slightly_smiling_face:.

Hope it helped!

1 Like

Hi @liamnichols, thanks for response!
Good answer! This is great!

Kind regards.

1 Like