You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mw...@apache.org on 2013/03/20 22:08:42 UTC
git commit: [CB-2733] Consistently throw an Error object.
Updated Branches:
refs/heads/master 5ba321a21 -> 44fd17d08
[CB-2733] Consistently throw an Error object.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/44fd17d0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/44fd17d0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/44fd17d0
Branch: refs/heads/master
Commit: 44fd17d08332ff56620f488758d2c2b286dd3ea7
Parents: 5ba321a
Author: Michael Brooks <mi...@michaelbrooks.ca>
Authored: Wed Mar 20 14:08:17 2013 -0700
Committer: Michael Brooks <mi...@michaelbrooks.ca>
Committed: Wed Mar 20 14:08:17 2013 -0700
----------------------------------------------------------------------
src/create.js | 2 +-
src/hooker.js | 4 ++--
src/metadata/blackberry_parser.js | 4 ++--
src/plugin.js | 2 +-
src/serve.js | 8 ++++----
5 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/44fd17d0/src/create.js
----------------------------------------------------------------------
diff --git a/src/create.js b/src/create.js
index c4ddb1d..0f7c8a6 100644
--- a/src/create.js
+++ b/src/create.js
@@ -53,7 +53,7 @@ module.exports = function create (dir, id, name) {
// Check for existing cordova project
if (fs.existsSync(dotCordova)) {
- throw 'Cordova project already exists at ' + dir + ', aborting.';
+ throw new Error('Cordova project already exists at ' + dir + ', aborting.');
}
// Create basic project structure.
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/44fd17d0/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index dccdfe3..8903fdb 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -25,7 +25,7 @@ var shell = require('shelljs'),
module.exports = function hooker(root) {
var r = util.isCordova(root);
- if (!r) throw "Not a Cordova project, can't use hooks.";
+ if (!r) throw new Error('Not a Cordova project, can\'t use hooks.');
else this.root = r;
}
@@ -43,7 +43,7 @@ module.exports.prototype = {
var fullpath = path.join(dir, script);
if (fs.statSync(fullpath).isDirectory()) return; // skip directories if they're in there.
var status = shell.exec(fullpath);
- if (status.code != 0) throw 'Script "' + path.basename(script) + '"' + 'in the ' + hook + ' hook exited with non-zero status code. Aborting.';
+ if (status.code !== 0) throw new Error('Script "' + path.basename(script) + '"' + 'in the ' + hook + ' hook exited with non-zero status code. Aborting.');
});
return true;
}
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/44fd17d0/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index ae1742c..b2cad4b 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -41,7 +41,7 @@ module.exports.check_requirements = function(callback) {
module.exports.prototype = {
update_from_config:function(config) {
if (config instanceof config_parser) {
- } else throw 'update_from_config requires a config_parser object';
+ } else throw new Error('update_from_config requires a config_parser object');
this.xml.name(config.name());
this.xml.packageName(config.packageName());
@@ -182,7 +182,7 @@ module.exports.prototype = {
description:'Enter the password for your BB10 simulator'
}
], function(err, results) {
- if (err) throw 'Error during BlackBerry environment config retrieval';
+ if (err) throw new Error('Error during BlackBerry environment config retrieval');
// Write out .cordova/config.json file
if (dot.blackberry === undefined) dot.blackberry = {};
if (dot.blackberry.qnx === undefined) dot.blackberry.qnx = {};
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/44fd17d0/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index d914df2..10de2d5 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -186,7 +186,7 @@ module.exports = function plugin(command, targets, callback) {
hooks.fire('after_plugin_rm');
} else {
- throw 'Plugin "' + targetName + '" not added to project.';
+ throw new Error('Plugin "' + targetName + '" not added to project.');
}
});
if (callback) callback();
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/44fd17d0/src/serve.js
----------------------------------------------------------------------
diff --git a/src/serve.js b/src/serve.js
index b15f907..9d86b14 100644
--- a/src/serve.js
+++ b/src/serve.js
@@ -82,7 +82,7 @@ module.exports = function serve (platform, port) {
var projectRoot = cordova_util.isCordova(process.cwd());
if (!projectRoot) {
- throw 'Current working directory is not a Cordova-based project.';
+ throw new Error('Current working directory is not a Cordova-based project.');
}
var xml = path.join(projectRoot, 'www', 'config.xml');
@@ -91,11 +91,11 @@ module.exports = function serve (platform, port) {
// Retrieve the platforms.
var platforms = cordova_util.listPlatforms(projectRoot);
if (!platform) {
- throw 'You need to specify a platform.';
+ throw new Error('You need to specify a platform.');
} else if (platforms.length == 0) {
- throw 'No platforms to serve.';
+ throw new Error('No platforms to serve.');
} else if (platforms.filter(function(x) { return x == platform }).length == 0) {
- throw platform + ' is not an installed platform.';
+ throw new Error(platform + ' is not an installed platform.');
}
// If we got to this point, the given platform is valid.