Global error handling in JavaScript