micro-frontends icon indicating copy to clipboard operation
micro-frontends copied to clipboard

How to have error handling mechanism in microfrontends?

Open OneShiv opened this issue 3 years ago • 1 comments

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?

OneShiv avatar Sep 30 '21 06:09 OneShiv

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.

ukslim avatar Oct 01 '21 08:10 ukslim