We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a1d5015 commit c9c8bdbCopy full SHA for c9c8bdb
packages/util/src/index.ts
@@ -3,3 +3,4 @@ export * from './BigIntMath';
3
export * from './isNotNil';
4
export * from './replaceNullsToUndefineds';
5
export * from './serializableObject';
6
+export * from './network';
packages/util/src/network.ts
@@ -0,0 +1,13 @@
1
+/* eslint-disable @typescript-eslint/no-explicit-any */
2
+
+export const connectionErrorCodes = ['ENOTFOUND', 'ECONNREFUSED', 'ECONNRESET'];
+export const isConnectionError = (error: any) => {
+ if (
7
+ (error?.code && connectionErrorCodes.includes(error.code)) ||
8
+ (error?.message && connectionErrorCodes.some((err) => error.message.includes(err)))
9
+ ) {
10
+ return true;
11
+ }
12
+ return false;
13
+};
0 commit comments