Index: app/(app)/profile/actions.ts
===================================================================
--- app/(app)/profile/actions.ts	(revision 69d38f68301f35f7f19548e514390ac30521a75e)
+++ app/(app)/profile/actions.ts	(revision b04ba1e157677d8749211da255f2549e103aec19)
@@ -31,19 +31,29 @@
     }
 
-    // Email already exists check
-    const existing = await sql`
-        SELECT user_id FROM "user"
-        WHERE email = ${email} AND user_id != ${userId}
-    `;
-    if (existing.length > 0) {
-        return 'Email already exists.';
+    try {
+        // eslint-disable-next-line @typescript-eslint/no-explicit-any
+        await sql.begin(async (tx: any) => {
+            // Email already exists check
+            const existing = await tx`
+                SELECT user_id FROM "user"
+                WHERE email = ${email} AND user_id != ${userId}
+            `;
+            if (existing.length > 0) {
+                throw new Error('Email already exists.');
+            }
+
+            await tx`
+                UPDATE "user"
+                SET user_name = ${name},
+                    email = ${email}
+                WHERE user_id = ${userId}
+            `;
+        });
+    } catch (e: any) {
+        if (e instanceof Error && e.message === 'Email already exists.') {
+            return e.message;
+        }
+        throw e;
     }
-
-    await sql`
-        UPDATE "user"
-        SET user_name = ${name},
-            email = ${email}
-        WHERE user_id = ${userId}
-    `;
 
     redirect('/profile');
