Skip to content

Commit

Permalink
Address @leebyron review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Apr 3, 2018
1 parent bb2f7de commit 752b28a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/error/__tests__/GraphQLError-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ describe('GraphQLError', () => {
message: 'msg',
locations: undefined,
path: ['path', 3, 'to', 'field'],
extensions: undefined,
});
});

Expand Down
16 changes: 9 additions & 7 deletions src/error/formatError.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ import type { SourceLocation } from '../language/location';
*/
export function formatError(error: GraphQLError): GraphQLFormattedError {
invariant(error, 'Received null or undefined error.');
return {
message: error.message || 'An unknown error occurred.',
locations: error.locations,
path: error.path,
extensions: error.extensions,
};
const message = error.message || 'An unknown error occurred.';
const locations = error.locations;
const path = error.path;
const extensions = error.extensions;

return extensions
? { message, locations, path, extensions }
: { message, locations, path };
}

export type GraphQLFormattedError = {|
+message: string,
+locations: $ReadOnlyArray<SourceLocation> | void,
+path: $ReadOnlyArray<string | number> | void,
+extensions: { [key: string]: mixed } | void,
+extensions?: { [key: string]: mixed },
|};

0 comments on commit 752b28a

Please sign in to comment.