Skip to content

Commit

Permalink
fix(search): remove finally block as it's unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Mar 7, 2024
1 parent d850eaf commit ef8d963
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/lib/functions/fetchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@ export async function fetchResultsJSON(
try {
apiUrl = createApiUrl('search', params);
} catch (err: any) {
throw error(500, `Failed to create API URL: ${err.message}`);
} finally {
await delayed;
// Internal Server Error
throw error(500, `Failed to create API URL: ${err.message}`);
}

let response: Response;
try {
response = await fetch(apiUrl);
} catch (err: any) {
await delayed;
// Service Unavailable
throw error(503, `Failed to fetch results: ${err.message}`);
} finally {
await delayed;
}

const age: string | null = response.headers.get('age');
Expand All @@ -42,9 +41,9 @@ export async function fetchResultsJSON(
try {
results = await response.json();
} catch (err: any) {
throw error(500, `Failed to parse results: ${err.message}`);
} finally {
await delayed;
// Internal Server Error
throw error(500, `Failed to parse results: ${err.message}`);
}

await delayed;
Expand Down

0 comments on commit ef8d963

Please sign in to comment.