Skip to content

Commit

Permalink
fix(auth): handle error properly in loadCurrentUser (#9539)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AMoreaux authored Jan 10, 2025
1 parent 07fa58b commit 4ca03d0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/twenty-front/src/modules/auth/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4ca03d0

Please sign in to comment.