feat: add more error handling
This commit is contained in:
@@ -39,12 +39,17 @@ app.openapi(route, async (c) => {
|
||||
const page = Number(c.req.query("page") ?? 1);
|
||||
const limit = Number(c.req.query("limit") ?? 10);
|
||||
|
||||
const response = await fetchFromMultipleSources([
|
||||
const { result: response, errors } = await fetchFromMultipleSources([
|
||||
() => fetchSearchResultsFromAnilist(query, page, limit),
|
||||
() => fetchSearchResultsFromAmvstrm(query, page, limit),
|
||||
]);
|
||||
|
||||
if (!response) {
|
||||
return c.json({ success: false, results: [], hasNextPage: false }, 200);
|
||||
return c.json({
|
||||
success: (errors ?? []).length === 0,
|
||||
results: [],
|
||||
hasNextPage: false,
|
||||
});
|
||||
}
|
||||
|
||||
return c.json(
|
||||
|
||||
Reference in New Issue
Block a user