Skip to content

Commit 25c12d4

Browse files
committed
Change console.log to console.error for network error
console.error also logs the stack trace and the error cause. This will provide a lot more information to what went wrong. Before this change: `[Network error]: TypeError: fetch failed` After this change: ``` [Network error]: TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:11372:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { cause: Error: getaddrinfo ENOTFOUND xxx.example.com at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'xxx.example.com' } } ``` As you can see, after this change it's very clear that the endpoint is not available.
1 parent 900b71b commit 25c12d4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/source/data/error-handling.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const errorLink = onError(({ graphQLErrors, networkError }) => {
154154
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
155155
)
156156
);
157-
if (networkError) console.log(`[Network error]: ${networkError}`);
157+
if (networkError) console.error(`[Network error]: ${networkError}`);
158158
});
159159

160160
const httpLink = new HttpLink({ uri: 'http://localhost:4000/graphql' })

0 commit comments

Comments
 (0)