Error handling in action
The first thing we are going to do is stop our mock service. Yes, you heard it right – stop it. This way, the call to the getRecipes
service will fail because the server is down.
Now, if you refresh the front app, you will see that nothing is displayed. Our list of recipes is not displayed. Why do we get this behavior? Because we did not handle the errors. The error was thrown, the stream completed, and nothing happened afterward. We have a white screen where nothing is displayed. Open the console, and you will see the failed request:
You should be very careful about all the HTTP requests you raise in particular and all the processes in your front application in general. It is amazing to work with streams… when they are safe. So, how can we fix this? Just remember the strategies I have just told you. What strategy should we choose?
By the way, the last...