@lion/ajax
Advanced tools
Comparing version 1.2.1 to 1.2.2
{ | ||
"name": "@lion/ajax", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Thin wrapper around fetch with support for interceptors.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -8,3 +8,6 @@ export class AjaxFetchError extends Error { | ||
constructor(request, response, body) { | ||
super(`Fetch request to ${request.url} failed.`); | ||
super( | ||
`Fetch request to ${request.url} failed with status ${response.status} ${response.statusText}`, | ||
); | ||
this.name = 'AjaxFetchError'; | ||
this.request = request; | ||
@@ -11,0 +14,0 @@ this.response = response; |
@@ -582,2 +582,22 @@ import { expect } from '@open-wc/testing'; | ||
}); | ||
describe('AjaxFetchError', () => { | ||
it('has the name AjaxFetchError', () => { | ||
const error = new AjaxFetchError(new Request('/foobar'), new Response('foobar'), 'foobar'); | ||
expect(error.name).to.be.equal('AjaxFetchError'); | ||
}); | ||
it("displays the request failure text in it's message", () => { | ||
const error = new AjaxFetchError( | ||
new Request('/foobar'), | ||
new Response('foobar', { status: 418, statusText: "I'm a teapot" }), | ||
'foobar', | ||
); | ||
expect(error.message).to.include('http://localhost:8000/foobar'); | ||
expect(error.message).to.include('418'); | ||
expect(error.message).to.include("I'm a teapot"); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
183270
3113