Tweak some error messages & remove outdated comments

This commit is contained in:
Quentin Gliech
2024-11-15 09:43:44 +01:00
parent 425f4adeb4
commit edc49fef95
2 changed files with 5 additions and 8 deletions
+5 -6
View File
@@ -35,7 +35,6 @@ export const graphqlRequest = async <TData, TVariables>({
variables,
signal,
}: RequestOptions<TData, TVariables>): Promise<TData> => {
const stack = new Error().stack;
let response: Response;
try {
response = await fetch(graphqlEndpoint, {
@@ -50,15 +49,15 @@ export const graphqlRequest = async <TData, TVariables>({
signal,
});
} catch (cause) {
const e = new Error(`GraphQL to ${graphqlEndpoint} request failed`, {
throw new Error(`GraphQL request to ${graphqlEndpoint} request failed`, {
cause,
});
e.stack = stack;
throw e;
}
if (!response.ok) {
throw new Error(`GraphQL request failed: ${response.status}`);
throw new Error(
`GraphQL request to ${graphqlEndpoint} failed: ${response.status}`,
);
}
const json: ExecutionResult<TData> = await response.json();
@@ -67,7 +66,7 @@ export const graphqlRequest = async <TData, TVariables>({
}
if (!json.data) {
throw new Error("GraphQL request returned no data");
throw new Error(`GraphQL request to ${graphqlEndpoint} returned no data`);
}
return json.data;
-2
View File
@@ -15,8 +15,6 @@ import { afterAll, afterEach, beforeAll } from "vitest";
import { routeTree } from "../../src/routeTree.gen";
import { handlers } from "../mocks/handlers";
// Create a new router instance
export const server = setupServer(...handlers);
// Start server before all tests