Skip to content

Commit

Permalink
v1 - handle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
git-create-devben committed Jul 18, 2024
1 parent 9113e80 commit 4ad38eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/api/gemini/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ export async function POST(req: NextRequest) {
}, { status: 200 });
} catch (error: any) {
console.error('Server Error:', error.message);
let errorMessage = 'Something went wrong on the server';
let errorMessage = `Something went wrong on the server ${error.message}`;
let statusCode = 500;
if (error.message.includes('Google Places API Error')) {
errorMessage = 'Error fetching local services. Please try again later.';
errorMessage = `Error fetching local services. Please try again later. ${error.message}`;
statusCode = 503; // Service Unavailable
} else if (error.message.includes('Vertex AI') || error.message.includes('GOOGLE_APPLICATION_CREDENTIALS_JSON')) {
errorMessage = 'Error communicating with AI service. Please check the configuration and try again later.';
errorMessage = `Error communicating with AI service. Please check the configuration and try again later.${error.message}`;
statusCode = 503;
}
return NextResponse.json({ error: errorMessage }, { status: statusCode });
Expand Down

0 comments on commit 4ad38eb

Please sign in to comment.