neuland / micro-frontends

extending the microservice paradigms to web development
https://micro-frontends.org/
MIT License
4.57k stars 477 forks source link

How to have error handling mechanism in microfrontends? #59

Open OneShiv opened 3 years ago

OneShiv commented 3 years ago

I have read few blogs and it makes sense to have error handling responsibility given to each micro-frontend. But there might be scenarios where among micro-frontend you would like to have consistency in handling common errors specially for api status 400/500 ones. If we extract api abstraction layer into a package or in orchestrator application where should we put our error handling mechanism?

ukslim commented 3 years ago

One option is to have a micro-frontend dedicated to responding to such errors - I guess what you mean by "handling" is some sort of visible element saying "Something went wrong, please try again later" etc.

This MFE would listen for events published by other MFEs in the browser window. Now the only thing the MFEs experiencing the errors need to do, is publish the "This error happened to me" event. Look around for various mechanisms MFEs can communicate on an event bus. The Manning book suggests CustomEvent API.