MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / isNetworkError

Function isNetworkError

apps/desktop/main/update.ts:79–99  ·  view source on GitHub ↗

* 判断错误是否为网络相关错误

(error: Error)

Source from the content-addressed store, hash-verified

77 * 判断错误是否为网络相关错误
78 */
79function isNetworkError(error: Error): boolean {
80 const networkErrorKeywords = [
81 'ECONNREFUSED',
82 'ENOTFOUND',
83 'ETIMEDOUT',
84 'ECONNRESET',
85 'ENETUNREACH',
86 'EAI_AGAIN',
87 'socket hang up',
88 'network',
89 'connect',
90 'timeout',
91 'getaddrinfo',
92 ]
93 const errorMessage = error.message?.toLowerCase() || ''
94 const errorCode = (error as NodeJS.ErrnoException).code?.toLowerCase() || ''
95
96 return networkErrorKeywords.some(
97 (keyword) => errorMessage.includes(keyword.toLowerCase()) || errorCode.includes(keyword.toLowerCase())
98 )
99}
100
101/**
102 * 判断版本号是否为预发布版本

Callers 1

checkUpdateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected