fix(update-database-password): enhance error handling for password update failures

- Improved error messages when updating the database password to provide clearer guidance based on the error type.
- Added specific feedback for cases where the database container is not running, prompting users to start the service before attempting to change the password.
This commit is contained in:
Mauricio Siu
2026-04-04 00:22:19 -06:00
parent e1e175b1e0
commit 1506d8f21e
2 changed files with 11 additions and 3 deletions
@@ -56,12 +56,21 @@ export const UpdateDatabasePassword = ({
form.reset(); form.reset();
setIsOpen(false); setIsOpen(false);
} catch (e) { } catch (e) {
setError(e instanceof Error ? e.message : "Error updating password"); const raw = e instanceof Error ? e.message : "Error updating password";
const noContainer = raw.match(/No running container found for \S+/);
if (noContainer) {
setError(
"The database container is not running. Please start the service before changing the password.",
);
} else {
setError(
"Error updating password. Please check that the container is running and try again.",
);
}
} finally { } finally {
setIsPending(false); setIsPending(false);
} }
}; };
return ( return (
<Dialog <Dialog
open={isOpen} open={isOpen}
@@ -424,7 +424,6 @@ export const postgresRouter = createTRPCRouter({
fi fi
docker exec "$CONTAINER_ID" psql -U ${databaseUser} -c "ALTER USER \\"${databaseUser}\\" WITH PASSWORD '${password}';" docker exec "$CONTAINER_ID" psql -U ${databaseUser} -c "ALTER USER \\"${databaseUser}\\" WITH PASSWORD '${password}';"
`; `;
if (serverId) { if (serverId) {
await execAsyncRemote(serverId, command); await execAsyncRemote(serverId, command);
} else { } else {