MCPcopy Create free account
hub / github.com/dailydotdev/apps / isConnectionError

Function isConnectionError

packages/shared/src/lib/errors.ts:24–59  ·  view source on GitHub ↗
(error: Error | unknown)

Source from the content-addressed store, hash-verified

22};
23
24export const isConnectionError = (error: Error | unknown): boolean => {
25 // Check browser's online status first
26 if (typeof navigator !== 'undefined' && !navigator.onLine) {
27 return true;
28 }
29
30 if (!error) {
31 return false;
32 }
33
34 const errorMessage = error instanceof Error ? error.message : String(error);
35 const errorName = error instanceof Error ? error.name : '';
36
37 // Network-related error patterns
38 const connectionErrorPatterns = [
39 'Failed to fetch',
40 'Network request failed',
41 'NetworkError',
42 'Network Error',
43 'ERR_INTERNET_DISCONNECTED',
44 'ERR_NETWORK_CHANGED',
45 'ERR_CONNECTION_REFUSED',
46 'ERR_CONNECTION_RESET',
47 'ERR_CONNECTION_CLOSED',
48 'ERR_CONNECTION_TIMED_OUT',
49 'ENOTFOUND',
50 'ECONNREFUSED',
51 'ECONNRESET',
52 'ETIMEDOUT',
53 'offline',
54 ];
55
56 return connectionErrorPatterns.some(
57 (pattern) => errorMessage.includes(pattern) || errorName.includes(pattern),
58 );
59};

Callers 2

FeedErrorScreenFunction · 0.90
BootDataProviderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected