postal.js/example/standard/js/postal.diagnostics.js

18 lines
507 B
JavaScript
Raw Normal View History

postal.addWireTap(function(data, envelope) {
var all = _.extend(envelope, { data: data });
2011-09-14 15:02:14 +00:00
if(!JSON) {
2012-01-16 02:52:22 +00:00
throw "This browser or environment does not provide JSON support";
2011-09-14 15:02:14 +00:00
}
try {
console.log(JSON.stringify(all));
2011-09-14 15:02:14 +00:00
}
catch(exception) {
try {
2012-01-16 02:57:15 +00:00
all.data = "ERROR: " + exception.message;
console.log(JSON.stringify(all));
}
catch(ex) {
console.log("Unable to parse data to JSON: " + exception);
}
2011-09-14 15:02:14 +00:00
}
});