Improve profile update error messaging in AdminMemberManager
cgen-4cd86006a3da4b959be72ad0be00899a
This commit is contained in:
parent
3e3ea898fb
commit
b65d56f892
1 changed files with 11 additions and 3 deletions
|
|
@ -255,11 +255,19 @@ const AdminMemberManager = ({
|
||||||
await onRefresh();
|
await onRefresh();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Failed to update profile", error);
|
console.error("Failed to update profile", error);
|
||||||
|
const extractErrorMessage = (err: any) => {
|
||||||
|
if (!err) return "Supabase rejected the update. Review payload and RLS policies.";
|
||||||
|
if (typeof err === "string") return err;
|
||||||
|
if (err.message) return err.message;
|
||||||
|
try {
|
||||||
|
return JSON.stringify(err);
|
||||||
|
} catch (e) {
|
||||||
|
return String(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
aethexToast.error({
|
aethexToast.error({
|
||||||
title: "Profile update failed",
|
title: "Profile update failed",
|
||||||
description:
|
description: extractErrorMessage(error),
|
||||||
error?.message ||
|
|
||||||
"Supabase rejected the update. Review payload and RLS policies.",
|
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setSavingProfile(false);
|
setSavingProfile(false);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue