Created
May 6, 2009 14:56
-
-
Save hail2u/107547 to your computer and use it in GitHub Desktop.
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 formatNameAndEmail(name, email) { | |
if (typeof name !== "string" || typeof email !== "string") { | |
throw "InputIsNotString"; | |
} else if (formatNameAndEmail.arguments.length > 2) { | |
throw "ArgumentsTooLong"; | |
} else { | |
return name + " <" + email + ">"; | |
} | |
} | |
try { | |
var s = formatNameAndEmail("John Doe", "[email protected]", "Jane Doe", "[email protected]"); | |
} catch (e if e === "InputIsNotString") { | |
console.log("Input is not string."); | |
} catch (e if e === "ArgumentsTooLong") { | |
console.log("Argument is too long."); | |
} catch (e) { | |
console.log("Unknown error:" + e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment