Skip to content

Instantly share code, notes, and snippets.

@joekarma
Created August 12, 2012 17:53
Show Gist options
  • Save joekarma/3333401 to your computer and use it in GitHub Desktop.
Save joekarma/3333401 to your computer and use it in GitHub Desktop.
fugly antipattern
function handleMessage(message) {
try { /* master handler */
try { /* sub handler */
try { /* sub sub handler */
if (understandsMessage(message, "sub-sub-handler")) {
handleMessage(message, "sub-sub-handler");
} else {
throw "can't understand";
}
} catch (e) { throw e; }
} catch (e) {
if (understandsMessage(message, "sub-handler")) {
handleMessage(message, "sub-handler")
} else {
throw "can't understand";
}
}
} catch (e) {
if (understandsMessage(message, "master-handler")) {
handleMessage(message), "sub-handler")
} else {
throw "can't understand";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment