Skip to content

Commit

Permalink
feat: change error message when distro retrieval fails
Browse files Browse the repository at this point in the history
  • Loading branch information
bripkens committed Oct 24, 2023
1 parent 67b4a9c commit 548500a
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions src/app/validation/supported-distributions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,36 @@ import { NextResponse } from "next/server";
import { assertValue } from "~/lib/env";

export async function GET(): Promise<NextResponse> {
const response = await retryFetch(fetch)(
`${assertValue(
process.env.COLLECTOR_CONFIGURATION_VALIDATION_URL,
"COLLECTOR_CONFIGURATION_VALIDATION_URL env var is not configured"
)}/validation/supported-distributions`,
{
headers: {
"X-API-KEY": assertValue(
process.env.COLLECTOR_CONFIGURATION_VALIDATION_API_KEY,
"COLLECTOR_CONFIGURATION_VALIDATION_API_KEY env var is not configured"
),
let response: Response;

try {
response = await retryFetch(fetch)(
`${assertValue(
process.env.COLLECTOR_CONFIGURATION_VALIDATION_URL,
"COLLECTOR_CONFIGURATION_VALIDATION_URL env var is not configured"
)}/validation/supported-distributions`,
{
headers: {
"X-API-KEY": assertValue(
process.env.COLLECTOR_CONFIGURATION_VALIDATION_API_KEY,
"COLLECTOR_CONFIGURATION_VALIDATION_API_KEY env var is not configured"
),
},
retries: 3,
retryDelay: 1000,
retryOn: [500, 503],
}
);
} catch (e) {
console.error("Failed to retrieve supported distros", e);

return NextResponse.json(
{
error: "Failed to retrieve supported distributions",
},
retries: 3,
retryDelay: 1000,
retryOn: [500, 503],
}
);
{ status: 500 }
);
}

if (!response.ok) {
const body = await response.text();
Expand Down

0 comments on commit 548500a

Please sign in to comment.