Skip to content

Adds message to stack trace of GraphQLError. #718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/error/GraphQLError.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,6 @@ export function GraphQLError( // eslint-disable-line no-redeclare
path?: ?Array<string | number>,
originalError?: ?Error
) {
// Include (non-enumerable) stack trace.
if (originalError && originalError.stack) {
Object.defineProperty(this, 'stack', {
value: originalError.stack,
writable: true,
configurable: true
});
} else if (Error.captureStackTrace) {
Error.captureStackTrace(this, GraphQLError);
} else {
Object.defineProperty(this, 'stack', {
value: Error().stack,
writable: true,
configurable: true
});
}

// Compute locations in the source for the given nodes/positions.
let _source = source;
if (!_source && nodes && nodes.length > 0) {
Expand Down Expand Up @@ -165,6 +148,23 @@ export function GraphQLError( // eslint-disable-line no-redeclare
value: originalError
}
});

// Include (non-enumerable) stack trace.
if (originalError && originalError.stack) {
Object.defineProperty(this, 'stack', {
value: originalError.stack,
writable: true,
configurable: true
});
} else if (Error.captureStackTrace) {
Error.captureStackTrace(this, GraphQLError);
} else {
Object.defineProperty(this, 'stack', {
value: Error().stack,
writable: true,
configurable: true
});
}
}

(GraphQLError: any).prototype = Object.create(Error.prototype, {
Expand Down