Skip to content

Commit

Permalink
Adds message to stack trace of GraphQLError.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcr committed Mar 20, 2017
1 parent 7c044c6 commit 11f3631
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/error/GraphQLError.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ export function GraphQLError( // eslint-disable-line no-redeclare
path?: ?Array<string | number>,
originalError?: ?Error
) {
// Define message so it can be captured in stack trace.
Object.defineProperty(this, 'message', {
value: message,
// By being enumerable, JSON.stringify will include `message` in the
// resulting output. This ensures that the simplist possible GraphQL
// service adheres to the spec.
enumerable: true,
writable: true
});

// Include (non-enumerable) stack trace.
if (originalError && originalError.stack) {
Object.defineProperty(this, 'stack', {
Expand Down Expand Up @@ -117,14 +127,6 @@ export function GraphQLError( // eslint-disable-line no-redeclare
}

Object.defineProperties(this, {
message: {
value: message,
// By being enumerable, JSON.stringify will include `message` in the
// resulting output. This ensures that the simplist possible GraphQL
// service adheres to the spec.
enumerable: true,
writable: true
},
locations: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
Expand Down

0 comments on commit 11f3631

Please sign in to comment.