Improve award error messaging in AdminAchievementManager
cgen-a632e2d8230a4b378356ca3ce528a9a3
This commit is contained in:
parent
b65d56f892
commit
bfaaed46a5
1 changed files with 11 additions and 1 deletions
|
|
@ -110,9 +110,19 @@ const AdminAchievementManager = ({
|
|||
await loadUserAchievements(targetUser.id);
|
||||
} catch (error: any) {
|
||||
console.error("Failed to award achievement", error);
|
||||
const extractErrorMessage = (err: any) => {
|
||||
if (!err) return "Supabase rejected the award operation.";
|
||||
if (typeof err === "string") return err;
|
||||
if (err.message) return err.message;
|
||||
try {
|
||||
return JSON.stringify(err);
|
||||
} catch (e) {
|
||||
return String(err);
|
||||
}
|
||||
};
|
||||
aethexToast.error({
|
||||
title: "Award failed",
|
||||
description: error?.message || "Supabase rejected the award operation.",
|
||||
description: extractErrorMessage(error),
|
||||
});
|
||||
} finally {
|
||||
setAwarding(false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue