An immensely interesting set of slides on Enterprise JavaScript Error Handling can be found at https://web.archive.org/web/20140126104824/http://www.devhands.com/2008/10/javascript-error-handling-and-general-best-practices/
In short it summarizes:
- Assume your code will fail
- Log errors to the server
- You, not the browser, handle errors
- Identify where errors might occur
- Throw your own errors
- Distinguish fatal versus non-fatal errors
- Provide a debug mode
The slides go into much more detail and most probably will give you some direction.
EDIT:
The presentation mentioned above can be found here:
https://www.slideshare.net/nzakas/enterprise-javascript-error-handling-presentation