Skip to content

Instantly share code, notes, and snippets.

@liseferguson
Created March 11, 2018 17:42
Show Gist options
  • Save liseferguson/cd920df3d2700546cc6edbd8e17d5c94 to your computer and use it in GitHub Desktop.
Save liseferguson/cd920df3d2700546cc6edbd8e17d5c94 to your computer and use it in GitHub Desktop.
Error message drill
function main() {
try {
doAllTheThings();
}
catch(err) {
console.error(err);
reportError(err);
}
}
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);
@liseferguson
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment