Skip to content

Commit 11f3631

Browse files
committed
Adds message to stack trace of GraphQLError.
1 parent 7c044c6 commit 11f3631

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/error/GraphQLError.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ export function GraphQLError( // eslint-disable-line no-redeclare
7777
path?: ?Array<string | number>,
7878
originalError?: ?Error
7979
) {
80+
// Define message so it can be captured in stack trace.
81+
Object.defineProperty(this, 'message', {
82+
value: message,
83+
// By being enumerable, JSON.stringify will include `message` in the
84+
// resulting output. This ensures that the simplist possible GraphQL
85+
// service adheres to the spec.
86+
enumerable: true,
87+
writable: true
88+
});
89+
8090
// Include (non-enumerable) stack trace.
8191
if (originalError && originalError.stack) {
8292
Object.defineProperty(this, 'stack', {
@@ -117,14 +127,6 @@ export function GraphQLError( // eslint-disable-line no-redeclare
117127
}
118128

119129
Object.defineProperties(this, {
120-
message: {
121-
value: message,
122-
// By being enumerable, JSON.stringify will include `message` in the
123-
// resulting output. This ensures that the simplist possible GraphQL
124-
// service adheres to the spec.
125-
enumerable: true,
126-
writable: true
127-
},
128130
locations: {
129131
// Coercing falsey values to undefined ensures they will not be included
130132
// in JSON.stringify() when not provided.

0 commit comments

Comments
 (0)