When a MediaWiki action API request fails because of an error on the MediaWiki side, we have PHP error logging that allows people to be alerted and debug the error. When it fails for some other reason, the situation is more murky.
In particular, in order to be able to know whether normal users of web browsers are affected by the new API rate limits (as opposed to the scrapers that the limits are intended for), and to have some idea about which components are making too many API requests, we should log it on the client side when an action API request fails with a HTTP 429 error.