Asynchronous errors in a promise chain are handled with .catch(), which intercepts any rejection that occurred earlier in the chain, and with .finally() for cleanup code. A rejected promise with no handler causes an "unhandled rejection" error: every chain should end with a catch.
Example
charger()
.then(afficher)
.catch((e) => console.error(e))
.finally(masquerChargement)