aboutsummaryrefslogtreecommitdiffstats
path: root/lib/prompts.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-07-24 21:35:13 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-07-24 21:35:13 +0200
commitc6b878fcd9291c6f0eb310f6f9c76cd0b6289030 (patch)
tree21bad4870d680be6bea8992a856c8c43cd704019 /lib/prompts.js
parent1ee62a82426490bfc6d4177e58c836b59a0823f6 (diff)
downloadbugzilla-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
Diffstat (limited to 'lib/prompts.js')
-rw-r--r--lib/prompts.js7
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);