Skip to content

Instantly share code, notes, and snippets.

@schamblee
Created January 19, 2018 20:13
Show Gist options
  • Save schamblee/b000c8dc4014e001948232df8d1fe67d to your computer and use it in GitHub Desktop.
Save schamblee/b000c8dc4014e001948232df8d1fe67d to your computer and use it in GitHub Desktop.
function doTrafficLights() {
const activeLight = getActiveLight();
if (activeLight === 'red') {
turnRed()
} else if (activeLight ==="green") {
turnGreen()
} else {
turnYellow()
}
}
function main() {
try {
doAllTheThings();
} catch(e) {
console.error(e);
reportError(e);
}
}
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment