From 84c60320fade8c8d940b1185addbb5b2291e0866 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Wed, 12 Nov 2025 22:42:43 +0100 Subject: [PATCH] Add proper error handling for session ID clashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/app.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app.ts b/src/app.ts index 6b585f5..9a778af 100644 --- a/src/app.ts +++ b/src/app.ts @@ -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); } });