Skip to content

Commit

Permalink
put try/catch around JSON.parse calls
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Oct 27, 2014
1 parent 9ab5bc4 commit 66b83b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion public/hft/0.x.x/scripts/virtualsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,14 @@ define(function() {
sendLowLevel('P');
return;
}
fn(JSON.parse(event.data));
try {
var obj = JSON.parse(event.data);
} catch (e) {
console.log(e);
}
if (obj) {
fn(obj);
}
};
break;
}
Expand Down
6 changes: 5 additions & 1 deletion server/websocketserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ var WSServer = function(server) {
return;
}
if (origFn) {
origFn(JSON.parse(data));
try {
origFn(JSON.parse(data));
} catch (e) {
console.error(e);
}
}
};
}(fn);
Expand Down

0 comments on commit 66b83b8

Please sign in to comment.