Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mixpanel-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var create_client = function(token, config) {
}
}
catch(ex) {
e = new Error("Could not parse response from Mixpanel");
e = new Error("Could not parse response from Mixpanel: " + JSON.stringify(data));
}
}
else {
Expand Down
29 changes: 29 additions & 0 deletions test/send_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,35 @@ exports.send_request = {
this.res.emit('end');
},

"handles mixpanel verbose errors": function(test) {
test.expect(1);
this.mixpanel.config.verbose = true;
this.mixpanel.send_request("/track", { event: "test" }, function(e) {
test.equal(e.message, 'Mixpanel Server Error: Foobar');
test.done();
});

this.res.emit('data', JSON.stringify({
status: 0,
error: 'Foobar'
}));
this.res.emit('end');
this.mixpanel.config.verbose = false;
},

"handles mixpanel verbose errors with non-verbose response": function(test) {
test.expect(1);
this.mixpanel.config.verbose = true;
this.mixpanel.send_request("/track", { event: "test" }, function(e) {
test.equal(e.message, 'Could not parse response from Mixpanel: ""');
test.done();
});

this.res.emit('data', '');
this.res.emit('end');
this.mixpanel.config.verbose = false;
},

"handles http.get errors": function(test) {
test.expect(1);
this.mixpanel.send_request("/track", { event: "test" }, function(e) {
Expand Down