diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-07-24 21:35:13 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-07-24 21:35:13 +0200 |
commit | c6b878fcd9291c6f0eb310f6f9c76cd0b6289030 (patch) | |
tree | 21bad4870d680be6bea8992a856c8c43cd704019 | |
parent | 1ee62a82426490bfc6d4177e58c836b59a0823f6 (diff) | |
download | bugzilla-triage-c6b878fcd9291c6f0eb310f6f9c76cd0b6289030.tar.gz |
undefined !== null and if (undefined) is not if (null)
- prompts.prompt* should return null when cancelled
- don't return undefined when you meant to throw an exception
-rw-r--r-- | lib/prompts.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/prompts.js b/lib/prompts.js index 779ef8d..bf37818 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -36,7 +36,7 @@ exports.prompt = function prompt(prompt, defaultValue) { if (result) { return stringValue.value; } else { - return undefined; + return null; } }; @@ -65,7 +65,7 @@ exports.promptPassword = function promptPassword(prompt) { if (result) { return password.value ? password.value : null; } else { - return undefined; + return null; } }; @@ -75,8 +75,7 @@ exports.promptPassword = function promptPassword(prompt) { */ exports.promptYesNoCancel = function promptOKNoCancel(prompt) { if (!prompt) { // either undefined or null - console.error("Prompt is required!"); - return undefined; + throw new Error("Prompt is required!"); } var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"] .getService(Ci.nsIPromptService); |