streamline AI import and Workshop errors
This commit is contained in:
1 parent
7a2d6009f7
commit
944c674939
21 files changed
+149
-109
No files matched your search
@@ -257,6 +257,13 @@ function workshopError(error: unknown, fallback: string) {
|
||||
/invalid|missing|not found|failed/iu.test(rawMessage)
|
||||
)
|
||||
return new Error("GitHub sign-in is not configured correctly on the Workshop server.", { cause: error });
|
||||
if (
|
||||
(error instanceof ClientResponseError && error.status === 0) ||
|
||||
/networkerror|failed to fetch|fetch failed|load failed|connection (?:refused|reset)|econn(?:refused|reset)|offline/iu.test(
|
||||
rawMessage,
|
||||
)
|
||||
)
|
||||
return new Error("Homarr Workshop seems to be unavailable right now. Try again in a moment.", { cause: error });
|
||||
if (error instanceof ClientResponseError) {
|
||||
const sdkMessage = error.data?.message || error.message;
|
||||
const originalMessage =
|
||||
|
||||
@@ -247,6 +247,16 @@ describe("WorkshopBackend", () => {
|
||||
expect(result.items).toHaveLength(1);
|
||||
expect(mocks.getFullList).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test("replaces low-level network errors with an actionable Workshop outage message", async () => {
|
||||
mocks.getList.mockRejectedValueOnce(new Error("NetworkError when attempting to fetch resource."));
|
||||
|
||||
const client = new WorkshopBackend("https://workshop.example.com");
|
||||
|
||||
await expect(client.list({ type: "customWidget" })).rejects.toThrow(
|
||||
"Homarr Workshop seems to be unavailable right now. Try again in a moment.",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function listingRecord() {
|
||||
|
||||
Reference in new issue
Block a user