Comparing version 0.1.4 to 0.1.5
@@ -125,2 +125,11 @@ 'use strict'; | ||
callback(err); | ||
} else if (typeof res === 'undefined' || typeof res.body === 'undefined') { | ||
/* | ||
* If we're in here then something very strange has happened because we didn't | ||
* get a properly formatted response from the API call, so give generic error | ||
* since that's the best we can do in this case | ||
* | ||
* Note that this is the case for both successful responses and error responses | ||
*/ | ||
callback(new Error('Unexpected error occurred while trying to send transmission')); | ||
} else if (res.statusCode !== 200) { | ||
@@ -127,0 +136,0 @@ callback(res.body.errors); |
{ | ||
"name": "sparkpost", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "A Node.js wrapper for interfacing with your favorite SparkPost APIs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,3 +18,3 @@ function MockRequest() { | ||
MockRequest.prototype.post = function(options, callbackFunction) { | ||
var response = {error: this.error, response: this.response, body: this.response.body}; | ||
var response = {error: this.error, response: this.response, body: this.response.body || undefined}; | ||
callbackFunction(response.error, response.response, response.body); | ||
@@ -21,0 +21,0 @@ }; |
@@ -173,2 +173,14 @@ var chai = require('chai') | ||
it('should return a generic error when we get an ill-formed response from the API', function() { | ||
MockRequest.response = {}; // no body | ||
transmission.send({}, function(err, res) { | ||
expect(res).to.be.undefined; | ||
expect(err).to.match(/Unexpected error occurred while trying to send transmission/); | ||
}); | ||
MockRequest.restore(); | ||
}); | ||
it('should return an error if the status code is anything other than 200', function() { | ||
@@ -175,0 +187,0 @@ MockRequest.response.statusCode = 500; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88467
1622