planet-client
Advanced tools
Comparing version 0.14.0 to 0.15.0-beta.1
@@ -125,2 +125,15 @@ /** | ||
/** | ||
* An error generated on the client side, before issuing a request. | ||
* @param {string} message Error message. | ||
* @constructor | ||
* @ignore | ||
*/ | ||
function ClientError(message) { | ||
this.message = message; | ||
this.stack = (new Error()).stack; | ||
} | ||
ClientError.prototype = new Error(); | ||
ClientError.prototype.name = 'ClientError'; | ||
exports.ResponseError = ResponseError; | ||
@@ -132,1 +145,2 @@ exports.BadRequest = BadRequest; | ||
exports.AbortedRequest = AbortedRequest; | ||
exports.ClientError = ClientError; |
@@ -245,2 +245,5 @@ /** | ||
var client = protocol.request(options, handler); | ||
client.on('error', function(err) { | ||
reject(new errors.ClientError(err.message)); | ||
}); | ||
if (config.body) { | ||
@@ -247,0 +250,0 @@ client.write(JSON.stringify(config.body)); |
{ | ||
"name": "planet-client", | ||
"version": "0.14.0", | ||
"version": "0.15.0-beta.1", | ||
"description": "A client for Planet's imagery API", | ||
@@ -40,3 +40,2 @@ "repository": { | ||
"coveralls": "^2.11.3", | ||
"envify": "^3.2.0", | ||
"eslint": "^0.22.1", | ||
@@ -68,2 +67,3 @@ "eslint-config-planet": "^2.0.0", | ||
"bole": "^2.0.0", | ||
"envify": "^3.2.0", | ||
"jwt-claims": "^1.0.1", | ||
@@ -70,0 +70,0 @@ "os-homedir": "^1.0.0", |
@@ -8,2 +8,3 @@ /* eslint-env mocha */ | ||
var stream = require('readable-stream'); | ||
var createMockRequest = require('../util').createMockRequest; | ||
@@ -51,7 +52,3 @@ var request = require('../../api/request'); | ||
beforeEach(function() { | ||
mockRequest = { | ||
write: sinon.spy(), | ||
end: sinon.spy(), | ||
abort: sinon.spy() | ||
}; | ||
mockRequest = createMockRequest(); | ||
http.request = sinon.spy(function() { | ||
@@ -58,0 +55,0 @@ return mockRequest; |
@@ -10,2 +10,3 @@ /* eslint-env mocha */ | ||
var createMockRequest = require('../util').createMockRequest; | ||
var auth = require('../../api/auth'); | ||
@@ -26,7 +27,3 @@ var authStore = require('../../api/auth-store'); | ||
beforeEach(function() { | ||
mockRequest = { | ||
write: sinon.spy(), | ||
end: sinon.spy(), | ||
abort: sinon.spy() | ||
}; | ||
mockRequest = createMockRequest(); | ||
http.request = sinon.spy(function() { | ||
@@ -33,0 +30,0 @@ return mockRequest; |
@@ -15,2 +15,3 @@ /* eslint-env mocha */ | ||
var util = require('../../api/util'); | ||
var createMockRequest = require('../util').createMockRequest; | ||
@@ -27,7 +28,3 @@ chai.config.truncateThreshold = 0; | ||
beforeEach(function() { | ||
mockRequest = { | ||
_read: sinon.spy(), | ||
end: sinon.spy(), | ||
abort: sinon.spy() | ||
}; | ||
mockRequest = createMockRequest(); | ||
var httpRequestMock = http.request = sinon.spy(function() { | ||
@@ -320,2 +317,21 @@ return mockRequest; | ||
it('rejects with ClientError when there is a client error', function(done) { | ||
mockRequest.on = function(event, callback) { | ||
setTimeout(function() { | ||
callback(new Error('Network Error')); | ||
}, 10); | ||
}; | ||
var promise = request({url: 'http://example.com'}); | ||
promise.then(function(obj) { | ||
done(new Error('Expected promise to be rejected')); | ||
}, function(err) { | ||
assert.instanceOf(err, errors.ClientError); | ||
assert.equal(err.message, 'Network Error'); | ||
done(); | ||
}).catch(done); | ||
}); | ||
it('accepts a terminator for aborting requests', function(done) { | ||
@@ -322,0 +338,0 @@ var promise = request({ |
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
148505
24
65
4221
8
+ Addedenvify@^3.2.0
+ Addedacorn@5.7.4(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedast-types@0.9.6(transitive)
+ Addedbase62@1.2.8(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcommoner@0.10.8(transitive)
+ Addeddefined@1.0.1(transitive)
+ Addeddetective@4.7.1(transitive)
+ Addedenvify@3.4.1(transitive)
+ Addedesprima@3.1.3(transitive)
+ Addedesprima-fb@15001.1.0-dev-harmony-fb(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedjstransform@11.0.3(transitive)
+ Addedobject-assign@2.1.1(transitive)
+ Addedprivate@0.1.8(transitive)
+ Addedq@1.5.1(transitive)
+ Addedrecast@0.11.23(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsource-map@0.4.40.5.7(transitive)