fix: extract actual error from Edge Function response

This commit is contained in:
Kurdistan Tech Ministry committed 2026-02-07 06:35:00 +03:00
1 parent 5c6a3f5e67
commit 6b0fb5b90b
3 files changed
+15 -6

No files matched your search

+11 -2
View File
@@ -164,8 +164,17 @@ export function useAnnouncementReaction() {
});
if (error) {
console.error('[useAnnouncementReaction] Edge function error:', error);
throw new Error(error.message || 'Failed to process reaction');
let msg = error.message || 'Failed';
try {
const body = error.context?.body;
if (body) {
const parsed = JSON.parse(body);
if (parsed.error) msg = parsed.error;
}
} catch {
// ignore parse errors
}
throw new Error(msg);
}
if (data?.error) {