Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Fix error messages for non-Chrome browsers. (#1568)
Browse files Browse the repository at this point in the history
Check if error.stack contains error.message, and if not, append it to the error message
printed to the console.
This should fix error messages in Firefox and Safari.
  • Loading branch information
nchevobbe authored and James Baxley committed Jan 24, 2018
1 parent 9222ab3 commit 76e8b66
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,16 @@ export default function graphql<
// _feel_ like it was logged ASAP while still tolerating asynchrony.
let logErrorTimeoutId = setTimeout(() => {
if (error) {
let errorMessage = error;
if (error.stack) {
errorMessage = error.stack.includes(error.message)
? error.stack
: `${error.message}\n${error.stack}`;
}

console.error(
`Unhandled (in react-apollo:${graphQLDisplayName})`,
error.stack || error,
errorMessage,
);
}
}, 10);
Expand Down

0 comments on commit 76e8b66

Please sign in to comment.