Restartable error handling system for JavaScript