Skip to content

Commit

Permalink
added error checking in new dropelets
Browse files Browse the repository at this point in the history
  • Loading branch information
hortinstein committed May 20, 2013
1 parent 3ba0d85 commit a9ad2dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions .c9revisions/package.json.c9save
@@ -1 +1,2 @@
{"ts":1368496336696,"silentsave":true,"restoring":false,"patch":[[{"diffs":[[1,"{\n \"name\": \"brinydeep\",\n \"version\": \"0.0.3\",\n \"description\": \"node.js wrapper for Digital Ocean's API\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"mocha -t 40000 test/test.js\",\n \"start\": \"index.js\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/hortinstein/brinydeep.git\"\n },\n \"keywords\": [\n \"digitalocean\",\n \"digital\",\n \"ocean\",\n \"api\",\n \"cloud\",\n \"ssd\"\n ],\n \"dependencies\": {\n \"request\": \"*\",\n \"mocha\": \"*\",\n \"async\": \"~0.2.5\",\n \"should\": \"~1.2.1\"\n },\n \"author\": \"hortinstein\",\n \"license\": \"BSD\",\n \"readmeFilename\": \"README.md\"\n}\n"]],"start1":0,"start2":0,"length1":0,"length2":609}]],"length":609}
{"contributors":[],"silentsave":false,"ts":1369051176417,"patch":[[{"diffs":[[0,"\": \"0.0."],[1,"5"],[0,"3\",\n \"d"]],"start1":35,"start2":35,"length1":16,"length2":17},{"diffs":[[0,": \"~1.2."],[-1,"1"],[1,"2"],[0,"\"\n },\n "]],"start1":513,"start2":513,"length1":17,"length2":17}]],"length":610,"saved":false}
18 changes: 11 additions & 7 deletions index.js
Expand Up @@ -76,15 +76,19 @@ brinydeep.new_droplets = function (options,callback) {
options = requestor.build_requests('droplets','/',new_machine_req);
requestor.send_request(options,function (e,o) {
//adds to a locally stored array of created droplets
if (Array.isArray(o)){
for (droplet in o) {
var id = o[droplet].droplet.id;
//console.log(id);
ids_created_this_session.push(id);
if (Array.isArray(o)){
for (var droplet in o) {
if (o[droplet].status === 'OK']){
var id = o[droplet].droplet.id;
//console.log(id);
ids_created_this_session.push(id);
}
}
} else {
var id = o.droplet.id;
ids_created_this_session.push(id);
if (o.status === 'OK']){
var t_id = o.droplet.id;
ids_created_this_session.push(t_id);
}
}
callback(e,o);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "brinydeep",
"version": "0.0.51",
"version": "0.0.53",
"description": "node.js wrapper for Digital Ocean's API",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a9ad2dd

Please sign in to comment.