Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write a global error handler in JavaScript?
The following global error handler will show how to catch unhandled exception −
Example
<!DOCTYPE html>
<html>
<body>
<script>
window.onerror = function(errMsg, url, line, column, error) {
var result = !column ? '' : '
column: ' + column;
result += !error;
document.write("Error= " + errMsg + "
url= " + url + "
line= " + line + result);
var suppressErrorAlert = true;
return suppressErrorAlert;
};
setTimeout(function() {
eval("{");
}, 500)
</script>
</body>
</html>Advertisements