Skip to content
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
5 changes: 0 additions & 5 deletions apps/ensindexer/src/lib/version-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

import { prettifyError } from "zod/v4";

import type { ENSIndexerVersionInfo, SerializedENSIndexerVersionInfo } from "@ensnode/ensnode-sdk";
import { makeENSIndexerVersionInfoSchema } from "@ensnode/ensnode-sdk/internal";

/**
* Get ENSIndexer version
*/
Expand Down
26 changes: 3 additions & 23 deletions packages/ensrainbow-sdk/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,30 +317,10 @@ describe("EnsRainbowApiClient", () => {
expect(response).toEqual(configData);
});

it("should throw with server error message when response is not ok", async () => {
mockFetch.mockResolvedValueOnce({
ok: false,
statusText: "Internal Server Error",
json: () =>
Promise.resolve({
error: "Database not ready",
errorCode: 500,
}),
});

await expect(client.config()).rejects.toThrow("Database not ready");
});

it("should throw with fallback message when error body has no error field", async () => {
mockFetch.mockResolvedValueOnce({
ok: false,
statusText: "Service Unavailable",
json: () => Promise.resolve({}),
});
it("should throw with fallback message when error body is not valid JSON", async () => {
mockFetch.mockResolvedValueOnce({ ok: false, statusText: "Not Found" });

await expect(client.config()).rejects.toThrow(
"Failed to fetch ENSRainbow config: Service Unavailable",
);
await expect(client.config()).rejects.toThrow(/Not Found/);
});
});
});
Expand Down
5 changes: 1 addition & 4 deletions packages/ensrainbow-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,7 @@ export class EnsRainbowApiClient implements EnsRainbow.ApiClient {
const response = await fetch(new URL("/v1/config", this.options.endpointUrl));

if (!response.ok) {
const errorData = (await response.json()) as { error?: string; errorCode?: number };
throw new Error(
errorData.error ?? `Failed to fetch ENSRainbow config: ${response.statusText}`,
);
throw new Error(`Failed to fetch ENSRainbow config: ${response.statusText}`);
}

return response.json() as Promise<EnsRainbow.ENSRainbowPublicConfig>;
Expand Down
Loading