Add proper error handling for session ID clashes

Return 409 Conflict status when user-provided connection ID already exists, instead of generic 500 error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-12 22:42:43 +01:00
parent 10fa579de1
commit 84c60320fa

View File

@@ -152,6 +152,12 @@ export function createApp(storage: Storage, config: AppConfig) {
return c.json({ code }, 200);
} catch (err) {
console.error('Error creating offer:', err);
// Check if it's a session code clash error
if (err instanceof Error && err.message.includes('already exists')) {
return c.json({ error: err.message }, 409);
}
return c.json({ error: 'Internal server error' }, 500);
}
});