11// context/AuthContext.tsx
22import React , { createContext , useState , useEffect , useRef , useCallback } from "react" ;
3+ import type { AxiosError } from "axios" ;
34import { authStore } from "@store/authStore" ;
45import { authClient } from "@/utils/http/clients/authClient.client" ;
56import { apiClient } from "@/utils/http/clients/backendApiClientGeneral" ;
@@ -89,7 +90,9 @@ export const AuthProvider = (props: { children: React.ReactNode }) => {
8990 try {
9091 const stack = new Error ( ) . stack ;
9192 console . warn ( "loginSuccess called with undefined token, stack:\n" , stack ) ;
92- } catch { }
93+ } catch {
94+ // intentional empty catch for stack logging
95+ }
9396 }
9497 setIsAuthenticated ( true ) ;
9598 } ;
@@ -111,9 +114,9 @@ export const AuthProvider = (props: { children: React.ReactNode }) => {
111114 return false ;
112115 } catch ( error ) {
113116 console . error ( "Logout failed:" , {
114- message : ( error as any ) ?. message ,
115- response : ( error as any ) ?. response ?. data ,
116- status : ( error as any ) ?. response ?. status ,
117+ message : ( error as AxiosError ) ?. message ,
118+ response : ( error as AxiosError ) ?. response ?. data ,
119+ status : ( error as AxiosError ) ?. response ?. status ,
117120 } ) ;
118121 return false ;
119122 }
@@ -146,9 +149,9 @@ export const AuthProvider = (props: { children: React.ReactNode }) => {
146149 }
147150 } catch ( error ) {
148151 console . error ( "AuthContext.bootstrap: refresh failed:" , {
149- message : ( error as any ) ?. message ,
150- response : ( error as any ) ?. response ?. data ,
151- status : ( error as any ) ?. response ?. status ,
152+ message : ( error as AxiosError ) ?. message ,
153+ response : ( error as AxiosError ) ?. response ?. data ,
154+ status : ( error as AxiosError ) ?. response ?. status ,
152155 } ) ;
153156 // Avoid stale bootstrap failure overriding a successful OAuth callback login.
154157 if ( ! hasLoginSucceededRef . current && ! authStore . getToken ( ) ) {
0 commit comments