fix(auth): handle error properly in loadCurrentUser (#9539)

Updated the loadCurrentUser function to throw specific errors when an
API error occurs. This improves clarity and error handling, replacing
the generic "No current user result" exception.

Fix #9536
This commit is contained in:
Antoine Moreaux
2025-01-10 17:21:33 +01:00
committed by GitHub
parent 07fa58b042
commit 4ca03d0066

View File

@ -177,6 +177,10 @@ export const useAuth = () => {
const loadCurrentUser = useCallback(async () => {
const currentUserResult = await getCurrentUser();
if (isDefined(currentUserResult.error)) {
throw new Error(currentUserResult.error.message);
}
const user = currentUserResult.data?.currentUser;
if (!user) {