Skip to content

Render a more friendly error message for username conflicts

Warren Gifford requested to merge cloud/17552-better-error-message into main

Created by: flying-robot

When there is a username conflict during profile updates, an unfriendly duplicate key constraint error message is surfaced to the user along with a big "Error:" prefix. This runs afoul of our style guidelines and the experience we want our customers to have.

This changes that behavior (using a strategy employed elsewhere in the database code) to sniff out exactly what went wrong, and if it's a duplicate key violation we can show something more helpful ("Username is already in use.") The "Error:" prefix is similarly removed from the form alert.

Note that this only catches the specific case of username conflict. There are multiple returns that simply pass along err, but that's outside the scope of this change.

Screenshots

Success Screen Shot 2021-01-26 at 3 30 01 PM

Error Screen Shot 2021-01-26 at 3 30 14 PM

Fixes https://github.com/sourcegraph/sourcegraph/issues/17552

Merge request reports

Loading