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:
@ -177,6 +177,10 @@ export const useAuth = () => {
|
|||||||
const loadCurrentUser = useCallback(async () => {
|
const loadCurrentUser = useCallback(async () => {
|
||||||
const currentUserResult = await getCurrentUser();
|
const currentUserResult = await getCurrentUser();
|
||||||
|
|
||||||
|
if (isDefined(currentUserResult.error)) {
|
||||||
|
throw new Error(currentUserResult.error.message);
|
||||||
|
}
|
||||||
|
|
||||||
const user = currentUserResult.data?.currentUser;
|
const user = currentUserResult.data?.currentUser;
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|||||||
Reference in New Issue
Block a user