Skip to content

Commit

Permalink
fixes for wrong data being returned in errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thebigredgeek committed Apr 11, 2018
1 parent f8c0b8c commit 9d4ca8b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export declare class ApolloError extends ExtendableError {
locations: any;
_showLocations: boolean;
_showPath: boolean;
constructor(name: string, config: ErrorConfig, ctorData: any);
constructor(name: string, config: ErrorConfig, ctorConfig: ErrorConfig);
serialize(): ErrorInfo;
}
export declare const isInstance: (e: any) => boolean;
Expand Down
23 changes: 16 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ describe('createError', () => {
foo: 'bar'
});
});
it('uses original message and merges original data', () => {
const FooError = createError('FooError', {
message: 'A foo error has occurred',
data: {
hello: 'world'
},
options: {
showLocations: false,
showPath: true
}
});
const e = new FooError({data: {foo: 'bar'}});

const { message, name, time_thrown, data } = e.serialize();
expect(message).to.equal('A foo error has occurred');
expect(name).to.equal('FooError');
expect(time_thrown).to.equal(e.time_thrown);
expect(data).to.eql({ hello: 'world', foo: 'bar' });
});
});
context('when missing a config as the second parameter', () => {
it('throws an assertion error with a useful message', () => {
Expand Down

0 comments on commit 9d4ca8b

Please sign in to comment.