Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connection reset error message #288

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/graph-explorer/src/utils/createDisplayError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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({
Expand Down
6 changes: 6 additions & 0 deletions packages/graph-explorer/src/utils/createDisplayError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Loading