Create an mw.errorLog ResourceLoader module in core. The module should have two entry points:
- logException takes an exception (and optionally additional data) and reports it to the server.
- logError takes the same arguments as window.onerror and reports them to the server.
Reporting to the server means composing an error object, and sending it via one of three methods:
- AJAX request to a configurable endpoint
- GET parameters of a HTTP request to a configurable endpoint (with a fake image, the same way EventLogging does it)
- configurable callback function
The method and endpoint/callback should be configurable in LocalSettings.
At this point, it is OK to assume exceptions and onerror events behave the way they do in modern browsers. Unexpected input should not cause a new error, though.
The entry points should return an error id that can help the user to find or report the error. At this point it is fine to just return a random token (eventually this will be something like the hash of the error location). The error id should be reported home along with all other error data.