Skip to content

Conversation

@pgom
Copy link
Contributor

@pgom pgom commented Mar 20, 2018

Description

This PR adds the entire request response to the provided object. This will be more useful for failed requests, making it easier to debug what went wrong for that request.

Related issues

Copy link
Contributor

@SandroMachado SandroMachado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change the base error to include the response. WDYT?

expect(result.headers).toEqual({ 'biz-baz': 'buz' });
expect(result.status).toBe(201);
expect(result.url).toBe('foo');
expect(result.response).toEqual(result.response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix this test.

@pgom pgom force-pushed the enhancement/error-handling branch from aea82cf to 62cd3f6 Compare March 22, 2018 17:37
@pgom pgom requested a review from d-moreira March 22, 2018 18:06
@pgom pgom force-pushed the enhancement/error-handling branch 2 times, most recently from 92df5be to 23d565d Compare March 22, 2018 18:08
@SandroMachado
Copy link
Contributor

We need to add tests to cover this, right?

@pgom pgom force-pushed the enhancement/error-handling branch 3 times, most recently from e50f014 to ed6d838 Compare March 23, 2018 15:44
it('should create add an `response` attribute when provided', () => {
const error = createError({ status: 403 }, { foo: 'bar' });

expect(error.response).toEqual({ foo: 'bar' });
Copy link
Contributor

@SandroMachado SandroMachado Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT of also check the error instance?

@pgom pgom force-pushed the enhancement/error-handling branch from ed6d838 to eb3c581 Compare March 23, 2018 16:20
@SandroMachado SandroMachado merged commit f75afb1 into master Mar 23, 2018
@SandroMachado SandroMachado deleted the enhancement/error-handling branch March 23, 2018 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants