diff --git a/packages/graph-explorer/src/utils/createDisplayError.test.ts b/packages/graph-explorer/src/utils/createDisplayError.test.ts index 97e739e22..f4dd9e687 100644 --- a/packages/graph-explorer/src/utils/createDisplayError.test.ts +++ b/packages/graph-explorer/src/utils/createDisplayError.test.ts @@ -34,6 +34,14 @@ describe("createDisplayError", () => { }); }); + it("Should handle connection reset", () => { + const result = createDisplayError({ code: "ECONNRESET" }); + expect(result).toStrictEqual({ + title: "Connection reset", + message: "Please check your connection and try again.", + }); + }); + it("Should handle connection refused as inner error", () => { const error = new Error("Some error message string", { cause: { code: "ECONNREFUSED" }, @@ -45,6 +53,17 @@ describe("createDisplayError", () => { }); }); + it("Should handle connection reset as inner error", () => { + const error = new Error("Some error message string", { + cause: { code: "ECONNRESET" }, + }); + const result = createDisplayError(error); + expect(result).toStrictEqual({ + title: "Connection reset", + message: "Please check your connection and try again.", + }); + }); + it("Should handle AbortError", () => { const result = createDisplayError({ name: "AbortError" }); expect(result).toStrictEqual({ diff --git a/packages/graph-explorer/src/utils/createDisplayError.ts b/packages/graph-explorer/src/utils/createDisplayError.ts index 5c7bba85a..fea2e10fc 100644 --- a/packages/graph-explorer/src/utils/createDisplayError.ts +++ b/packages/graph-explorer/src/utils/createDisplayError.ts @@ -27,6 +27,12 @@ export function createDisplayError(error: any): DisplayError { message: "Please check your connection and try again.", }; } + if (error?.code === "ECONNRESET" || error?.cause?.code === "ECONNRESET") { + return { + title: "Connection reset", + message: "Please check your connection and try again.", + }; + } // Server timeout if (