Skip to content

Commit e1f3b20

Browse files
author
scf4
committed
removed undefined
1 parent 87e90fc commit e1f3b20

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ class ApolloError extends ExtendableError {
3838
const message = this._humanized_message;
3939
const time_thrown = this._time_thrown;
4040
const data = this._data;
41-
const locations = this._locations || undefined;
42-
const path = this._path || undefined;
43-
return {
41+
const locations = this._locations;
42+
const path = this._path;
43+
let error = {
4444
message,
4545
name,
4646
time_thrown,
4747
data,
48-
locations,
49-
path,
5048
};
49+
if (locations) error.locations = locations;
50+
if (path) error.path = path;
51+
return error;
5152
}
5253
}
5354

test/spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,15 @@ describe('createError', () => {
2727
},
2828
});
2929

30-
const { message, name, time_thrown, data, locations, path } = e.serialize();
31-
30+
const { message, name, time_thrown, data } = e.serialize();
31+
3232
expect(message).to.equal('A foo error has occurred');
3333
expect(name).to.equal('FooError');
3434
expect(time_thrown).to.equal(e._time_thrown);
3535
expect(data).to.eql({
3636
hello: 'world',
3737
foo: 'bar'
3838
});
39-
expect(locations).to.be.undefined;
40-
expect(path).to.be.undefined;
4139
});
4240
});
4341

0 commit comments

Comments
 (0)