Created
November 3, 2012 09:15
-
-
Save rainyjune/4006685 to your computer and use it in GitHub Desktop.
JavaScript Try Catch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Chrome Developer Tools</title> | |
</head> | |
<body> | |
<a href="#" id="c">click</a> | |
<script type="text/javascript"> | |
function t(x){ | |
if(x<10){ | |
throw new Error('bad parameter'); | |
} | |
return x*x; | |
} | |
try{ | |
t(3); | |
} | |
catch(e){ | |
alert(e.stack); | |
} | |
alert('uu'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment