Created
November 23, 2016 10:35
-
-
Save aylingumus/9dc5ed5781d2406c3ee3de205eac0449 to your computer and use it in GitHub Desktop.
Error Alert
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"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
* { | |
box-sizing: border-box; | |
} | |
main { | |
padding: 50px 20px; | |
} | |
.error-report { | |
color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<main> | |
<h1>Handling errors</h1> | |
<p class="error-report js-error-report"></p> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script> | |
</main> | |
<script id="jsbin-javascript"> | |
function main() { | |
try { | |
doAllTheThings(); | |
} | |
catch (error) { | |
console.error(error); | |
reportError(error); | |
} | |
} | |
function doAllTheThings() { | |
throw { | |
message: "Everything's ruined", | |
name: "FatalException", | |
toString: function(){return this.name + ": " + this.message;} | |
} | |
} | |
function reportError(e) { | |
$('.js-error-report').text("Uh oh, something went wrong! Here's what we know: " + e.message); | |
} | |
$(main); | |
</script> | |
<script id="jsbin-source-css" type="text/css">* { | |
box-sizing: border-box; | |
} | |
main { | |
padding: 50px 20px; | |
} | |
.error-report { | |
color: red; | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function main() { | |
try { | |
doAllTheThings(); | |
} | |
catch (error) { | |
console.error(error); | |
reportError(error); | |
} | |
} | |
function doAllTheThings() { | |
throw { | |
message: "Everything's ruined", | |
name: "FatalException", | |
toString: function(){return this.name + ": " + this.message;} | |
} | |
} | |
function reportError(e) { | |
$('.js-error-report').text("Uh oh, something went wrong! Here's what we know: " + e.message); | |
} | |
$(main);</script></body> | |
</html> |
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
function main() { | |
try { | |
doAllTheThings(); | |
} | |
catch (error) { | |
console.error(error); | |
reportError(error); | |
} | |
} | |
function doAllTheThings() { | |
throw { | |
message: "Everything's ruined", | |
name: "FatalException", | |
toString: function(){return this.name + ": " + this.message;} | |
} | |
} | |
function reportError(e) { | |
$('.js-error-report').text("Uh oh, something went wrong! Here's what we know: " + e.message); | |
} | |
$(main); |
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
* { | |
box-sizing: border-box; | |
} | |
main { | |
padding: 50px 20px; | |
} | |
.error-report { | |
color: red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment