mirror of
https://github.com/ostris/ai-toolkit.git
synced 2026-04-25 16:59:22 +00:00
Add better error messages if name exists when saving a job
This commit is contained in:
@@ -52,7 +52,13 @@ export async function POST(request: Request) {
|
||||
});
|
||||
return NextResponse.json(training);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (error.code === 'P2002') {
|
||||
// Handle unique constraint violation, 409=Conflict
|
||||
return NextResponse.json({ error: 'Job name already exists' }, { status: 409 });
|
||||
}
|
||||
console.error(error);
|
||||
// Handle other errors
|
||||
return NextResponse.json({ error: 'Failed to save training data' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user