Comparing version 0.4.0 to 0.4.1
ChangeLog | ||
========= | ||
0.4.1 (2017-07-07) | ||
------------------ | ||
* #38: Add HTTP response to HTTP-related exceptions. | ||
0.4.0 (2017-07-07) | ||
@@ -5,0 +11,0 @@ ------------------ |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var fetch = require('node-fetch'); | ||
var HttpError = require('./http-error'); | ||
@@ -46,3 +47,3 @@ var Resource = function(client, uri) { | ||
if (!response.ok) { | ||
throw new Error('HTTP error: ' + response.status); | ||
throw new HttpError(response); | ||
} | ||
@@ -71,3 +72,3 @@ | ||
if (!response.ok) { | ||
throw new Error('HTTP error: ' + response.status); | ||
throw new HttpError(response); | ||
} | ||
@@ -107,3 +108,3 @@ | ||
if (!response.ok) { | ||
throw new Error('HTTP error: ' + response.status); | ||
throw new HttpError(response); | ||
} | ||
@@ -136,3 +137,3 @@ | ||
if (!response.ok) { | ||
throw new Error('HTTP error: ' + response.status); | ||
throw new HttpError(response); | ||
} else { | ||
@@ -139,0 +140,0 @@ return response.json(); |
{ | ||
"name": "restl", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Opiniated HAL client.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -32,2 +32,15 @@ const Client = require('../../lib/client'); | ||
it('should throw an exception when there was a HTTP error', async() => { | ||
const resource = await client.follow('error400'); | ||
let exception; | ||
try { | ||
await resource.get(); | ||
} catch (ex) { | ||
exception = ex; | ||
} | ||
expect(exception.response.status).to.equal(400); | ||
}); | ||
}); |
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
45218
30
1075