Try and determine an error some HTTP requests are causing (#586)

This commit is contained in:
Matt Aitken
2023-10-08 17:20:07 +01:00
committed by GitHub
parent 0558b2c595
commit 6edaffeb7e
@@ -6,11 +6,24 @@ import { HandleHttpSourceService } from "~/services/sources/handleHttpSource.ser
export async function action({ request, params }: ActionArgs) {
logger.info("Handling http source", { url: request.url });
const { id } = z.object({ id: z.string() }).parse(params);
try {
const { id } = z.object({ id: z.string() }).parse(params);
const service = new HandleHttpSourceService();
const result = await service.call(id, request);
const service = new HandleHttpSourceService();
return await service.call(id, request);
return new Response(undefined, {
status: result.status,
});
} catch (e) {
if (e instanceof Error) {
logger.error("Error handling http source", { error: e.message });
} else {
logger.error("Error handling http source", { error: JSON.stringify(e) });
}
return new Response(undefined, {
status: 500,
});
}
}
export async function loader({ request, params }: LoaderArgs) {