Skip to content

Commit

Permalink
Added custom error reporting around JSON parsing of comet messages, j…
Browse files Browse the repository at this point in the history
…ust in case this didn't solve it. It will post relevant info to a server action that emails admin and nathan.
  • Loading branch information
nathansobo committed Dec 14, 2010
1 parent bfe9a7f commit f3d06d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 16 additions & 2 deletions lib/monarch/http/comet_client.js
Expand Up @@ -27,9 +27,23 @@ _.constructor("Monarch.Http.CometClient", {
numReceivedCharacters += unreadLines.length;
unreadLines = _.trim(unreadLines);
if (unreadLines.length === 0) return;

_.each(unreadLines.split("\n"), function(messageString) {
var message = JSON.parse(messageString);

try {
var message = JSON.parse(messageString);
} catch(e) {
// Special error handling added 12/14/10 -- Remove if we haven't seen any issues in a while
var errorReport = "In comet client, while attempting to parse the following JSON string:\n" +
messageString + "\n\n" +
e.stack;

if (window.console) {
console.debug("ERROR: " + errorReport);
}

Server.post("/client_error", {error: errorReport });
}

if (message[0] == "connected") {
connectFuture.triggerSuccess();
} else {
Expand Down
4 changes: 3 additions & 1 deletion vendor/underscore.js
Expand Up @@ -74,7 +74,9 @@
}
}
} catch(e) {
if (e != breaker) throw e;
if (e != breaker) {
throw e;
}
}
return obj;
};
Expand Down

0 comments on commit f3d06d7

Please sign in to comment.