Created
August 12, 2012 17:53
-
-
Save joekarma/3333401 to your computer and use it in GitHub Desktop.
fugly antipattern
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 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