Skip to content
Myr

Add request method and URL to error messages (#595)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Seth Holladay · committed by GitHub · parent 585ebcb · Browse files · 5 files+11 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+11 added−8 removed

  • tests:+9 added−6 removed
  • other:+2 added−2 removed

5 files+11 added−8 removed

modified:source/errors/HTTPError.ts+1 added-1 removed
modified:source/errors/TimeoutError.ts+1 added-1 removed
modified:test/browser.ts+2 added-2 removed
242 unmodified lines
243 if (typeof error !== 'object') {244 throw new TypeError('Expected to have an object error');245 }246247 t.is(error.message, 'TimeoutError: Request timed out');247 t.is(error.message, `TimeoutError: Request timed out: GET ${server.url}/slow`);248 t.is(error.request.url, `${server.url}/slow`);249 },250);251
227 unmodified lines
479 body: 'foo',480 method: 'PUT',481 retry: 1,482 }), server.url),483 {message: /HTTPError: Request failed with status code 502 Bad Gateway/},483 {message: /HTTPError: Request failed with status code 502 Bad Gateway: PUT/},484 );485486 t.is(requestCount, 2);487});
modified:test/hooks.ts+1 added-1 removed
480 unmodified lines
481 hooks: {482 beforeRetry: [483 async ({error, retryCount}) => {484 t.true(error instanceof HTTPError);485 t.is(error.message, 'Request failed with status code 502 Bad Gateway');485 t.is(error.message, `Request failed with status code 502 Bad Gateway: GET ${server.url}/`);486 t.true((error as HTTPError).response instanceof Response);487 t.deepEqual(await (error as HTTPError).response.json(), {awesome: true});488 t.is(retryCount, 1);489 t.is(requestCount, 1);
185 unmodified lines
modified:test/http-error.ts+6 added-3 removed