Skip to content

Commit 6edaffe

Browse files
authored
Try and determine an error some HTTP requests are causing (#586)
1 parent 0558b2c commit 6edaffe

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

apps/webapp/app/routes/api.v1.sources.http.$id.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@ import { HandleHttpSourceService } from "~/services/sources/handleHttpSource.ser
66
export async function action({ request, params }: ActionArgs) {
77
logger.info("Handling http source", { url: request.url });
88

9-
const { id } = z.object({ id: z.string() }).parse(params);
10-
11-
const service = new HandleHttpSourceService();
12-
13-
return await service.call(id, request);
9+
try {
10+
const { id } = z.object({ id: z.string() }).parse(params);
11+
const service = new HandleHttpSourceService();
12+
const result = await service.call(id, request);
13+
14+
return new Response(undefined, {
15+
status: result.status,
16+
});
17+
} catch (e) {
18+
if (e instanceof Error) {
19+
logger.error("Error handling http source", { error: e.message });
20+
} else {
21+
logger.error("Error handling http source", { error: JSON.stringify(e) });
22+
}
23+
return new Response(undefined, {
24+
status: 500,
25+
});
26+
}
1427
}
1528

1629
export async function loader({ request, params }: LoaderArgs) {

0 commit comments

Comments
 (0)