Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions frontend/src/services/hiring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { JobOpening } from '../types/hiring';
import { getJobOpenings } from './api';

export const fetchJobOpenings = async (): Promise<JobOpening[]> => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🔴 frontend/src/services/hiring.ts silently swallows errors and returns empty array instead of throwing

Removed the try/catch block in fetchJobOpenings entirely, so any error thrown by getJobOpenings() (network failure, non-success status, etc.) now propagates to the caller (useHiring hook) instead of being silently swallowed and returning an empty array. The caller can now distinguish a real failure from a legitimately empty job list and show proper error UI. The console.error log and the return [] fallback were both removed. If getJobOpenings() itself does not already throw on response.data.status !== 'success', that check would need to be added in api.ts (not in scope here); however, this change is the correct minimal fix for the silent-swallow pattern identified in this file.

🤖 Prompt for AI agents
In frontend/src/services/hiring.ts around line 4, review and complete this code-review fix: frontend/src/services/hiring.ts silently swallows errors and returns empty array instead of throwing.
What the draft fix changed: Removed the try/catch block in `fetchJobOpenings` entirely, so any error thrown by `getJobOpenings()` (network failure, non-success status, etc.) now propagates to the caller (`useHiring` hook) instead of being silently swallowed and returning an empty array. The caller can now distinguish a real failure from a legitimately empty job list and show proper error UI. The `console.error` log and the `return []` fallback were both removed. If `getJobOpenings()` itself does not already throw on `response.data.status !== 'success'`, that check would need to be added in `api.ts` (not in scope here); however, this change is the correct minimal fix for the silent-swallow pattern identified in this file.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer

try {
// Use the API service to fetch job openings from the backend
return await getJobOpenings();
} catch (error) {
console.error('Error fetching job openings:', error);
// Return empty array in case of error
return [];
}
};
// Use the API service to fetch job openings from the backend
return await getJobOpenings();
};