Skip to content

Ensures formatError gets a value that passes instanceof Error#1235

Merged
evans merged 4 commits into
version-2from
server-2.0/instanceof-errors
Jun 25, 2018
Merged

Ensures formatError gets a value that passes instanceof Error#1235
evans merged 4 commits into
version-2from
server-2.0/instanceof-errors

Conversation

@evans

@evans evans commented Jun 22, 2018

Copy link
Copy Markdown
Contributor

Fixes an issue brought up by @wKovacs64

@evans evans added this to the Release 2.0 milestone Jun 22, 2018

function enrichError(error: Partial<GraphQLError>, debug: boolean = false) {
const expanded = {} as any;
Object.setPrototypeOf(expanded, Object.getPrototypeOf(error));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or use Object.create(Object.getPrototypeOf(error), properties), with properties being the same object you pass to Object.defineProperties (so you don't need a separate call for that anymore).

@evans evans merged commit d85ef48 into version-2 Jun 25, 2018
@evans evans deleted the server-2.0/instanceof-errors branch June 25, 2018 23:36
@evans evans mentioned this pull request Jun 25, 2018
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants