Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better parse and error handling when reading revisions

  • Loading branch information...
commit c19be7f25decdfff303dbafb3be0625bac1cf6fb 1 parent cd50315
Sergi Mansilla authored
Showing with 16 additions and 7 deletions.
  1. +16 −7 plugins-server/cloud9.ide.revisions/revisions.js
View
23 plugins-server/cloud9.ide.revisions/revisions.js
@@ -196,22 +196,31 @@ require("util").inherits(RevisionsPlugin, Plugin);
return callback(err);
}
+ var error;
+ var lineCount = 0;
var lines = data.toString().split("\n");
- Async.forEachSeries(lines,
- function(line, next) {
+ if (lines.length) {
+ Async.whilst(
+ function () {
+ return (lineCount < lines.length && error === null);
+ },
+ function (next) {
try {
- if (line) {
- var revision = JSON.parse(line);
+ var revision = JSON.parse(lines[lineCount]);
revObj[revision.ts] = revision;
}
- }
catch(e) {
- console.error("Revision JSON Parse error", e.message, line);
+ error = e;
}
+ lineCount++;
next();
},
- function() { callback(null, revObj); });
+ function (e) {
+ callback(error, revObj);
+ }
+ );
+ }
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.