Created
January 19, 2018 20:13
-
-
Save schamblee/b000c8dc4014e001948232df8d1fe67d to your computer and use it in GitHub Desktop.
This file contains 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 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