@@ -180,9 +180,12 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
180180 }
181181 // setError(null);
182182 } catch ( error ) {
183- if ( error && Object . prototype . hasOwnProperty . call ( error , 'code' ) ) {
184- // setError(error);
185- }
183+ throw new AsgardeoRuntimeError (
184+ `Sign in failed: ${ error instanceof Error ? error . message : String ( JSON . stringify ( error ) ) } ` ,
185+ 'asgardeo-signIn-Error' ,
186+ 'react' ,
187+ 'An error occurred while trying to sign in.' ,
188+ ) ;
186189 }
187190 } else {
188191 // TODO: Add a debug log to indicate that the user is not signed in
@@ -418,7 +421,12 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
418421
419422 return response as User ;
420423 } catch ( error ) {
421- throw new Error ( `Error while signing in: ${ error instanceof Error ? error . message : String ( error ) } ` ) ;
424+ throw new AsgardeoRuntimeError (
425+ `Sign in failed: ${ error instanceof Error ? error . message : String ( JSON . stringify ( error ) ) } ` ,
426+ 'asgardeo-signIn-Error' ,
427+ 'react' ,
428+ 'An error occurred while trying to sign in.' ,
429+ ) ;
422430 } finally {
423431 if ( ! isV2FlowRequest ) {
424432 setIsUpdatingSession ( false ) ;
@@ -440,7 +448,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
440448 return response ;
441449 } catch ( error ) {
442450 throw new AsgardeoRuntimeError (
443- `Error while signing in silently: ${ error . message || error } ` ,
451+ `Error while signing in silently: ${ error instanceof Error ? error . message : String ( JSON . stringify ( error ) ) } ` ,
444452 'asgardeo-signInSilently-Error' ,
445453 'react' ,
446454 'An error occurred while trying to sign in silently.' ,
@@ -462,7 +470,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
462470 }
463471 } catch ( error ) {
464472 throw new AsgardeoRuntimeError (
465- `Failed to switch organization: ${ error . message || error } ` ,
473+ `Failed to switch organization: ${ error instanceof Error ? error . message : String ( JSON . stringify ( error ) ) } ` ,
466474 'asgardeo-switchOrganization-Error' ,
467475 'react' ,
468476 'An error occurred while switching to the specified organization.' ,
0 commit comments