Skip to content

Commit d4222f9

Browse files
tcrleebyron
authored andcommitted
Adds message to stack trace of GraphQLError. (#718)
* Adds message to stack trace of GraphQLError. * Fix typo in comment * Trailing spaces
1 parent 57b073a commit d4222f9

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/error/GraphQLError.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,6 @@ export function GraphQLError( // eslint-disable-line no-redeclare
8686
path?: ?Array<string | number>,
8787
originalError?: ?Error
8888
) {
89-
// Include (non-enumerable) stack trace.
90-
if (originalError && originalError.stack) {
91-
Object.defineProperty(this, 'stack', {
92-
value: originalError.stack,
93-
writable: true,
94-
configurable: true
95-
});
96-
} else if (Error.captureStackTrace) {
97-
Error.captureStackTrace(this, GraphQLError);
98-
} else {
99-
Object.defineProperty(this, 'stack', {
100-
value: Error().stack,
101-
writable: true,
102-
configurable: true
103-
});
104-
}
105-
10689
// Compute locations in the source for the given nodes/positions.
10790
let _source = source;
10891
if (!_source && nodes && nodes.length > 0) {
@@ -165,6 +148,23 @@ export function GraphQLError( // eslint-disable-line no-redeclare
165148
value: originalError
166149
}
167150
});
151+
152+
// Include (non-enumerable) stack trace.
153+
if (originalError && originalError.stack) {
154+
Object.defineProperty(this, 'stack', {
155+
value: originalError.stack,
156+
writable: true,
157+
configurable: true
158+
});
159+
} else if (Error.captureStackTrace) {
160+
Error.captureStackTrace(this, GraphQLError);
161+
} else {
162+
Object.defineProperty(this, 'stack', {
163+
value: Error().stack,
164+
writable: true,
165+
configurable: true
166+
});
167+
}
168168
}
169169

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

0 commit comments

Comments
 (0)