alphagov / govuk-frontend

GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.
https://frontend.design-system.service.gov.uk/
MIT License
1.17k stars 320 forks source link

Add callback to respond to errors when a component does not initialise in `createAll` #5212

Closed romaricpascal closed 1 month ago

romaricpascal commented 1 month ago

What

Add an option to createAll that allows services to pass a callback function to createAll that will be called if a component fails to initialise (or GOV.UK Frontend is not supported).

Why

So services can react to errors happening during component initialisation with createAll, for example sending a report to an error monitoring service

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

romaricpascal commented 1 month ago

As a starter, the callback will be added as third parameter, passed either in place of the scope or in an object that contains both scope and the callback. A future piece of work will look at avoiding to have to provide null when the component does not need a config.

patrickpatrickpatrick commented 1 month ago

Going to close as it's been merged into the WIP branch with documentation written for it.