Fix tag validation error messages not shown to user (#861)

This commit is contained in:
Chris 2026-02-24 14:49:49 +02:00 committed by GitHub
parent 782bed235b
commit 6e3b1b4099
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 3 deletions

View file

@ -1039,9 +1039,17 @@ const TaskDetails: React.FC = () => {
);
setTimelineRefreshKey((prev) => prev + 1);
} catch (error) {
} catch (error: any) {
console.error('Error updating tags:', error);
showErrorToast(t('task.tagsUpdateError', 'Failed to update tags'));
const details = error?.details;
if (details && Array.isArray(details) && details.length > 0) {
showErrorToast(details.join('. '));
} else {
showErrorToast(
error?.message ||
t('task.tagsUpdateError', 'Failed to update tags')
);
}
throw error;
}
};

View file

@ -29,7 +29,21 @@ export const handleAuthResponse = async (
}
throw new Error('Authentication required');
}
throw new Error(errorMessage);
let details: string[] | undefined;
try {
const body = await response.json();
if (body.details && Array.isArray(body.details)) {
details = body.details;
}
if (body.error) {
errorMessage = body.error;
}
} catch {
// response body is not JSON, use fallback errorMessage
}
const error = new Error(errorMessage);
(error as any).details = details;
throw error;
}
return response;
};