Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beasy-mobile
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
G
beasy-mobile
Commits
a36f44c3
Commit
a36f44c3
authored
Sep 09, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logic for handling error related to user informations fetching
parent
fbe2ec94
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
UserAuthenticationContext.tsx
src/contexts/UserAuthenticationContext.tsx
+6
-1
userInformations.ts
src/utils/requests/userInformations.ts
+15
-0
No files found.
src/contexts/UserAuthenticationContext.tsx
View file @
a36f44c3
import
authenticateUser
,
{
parseAuthicationErrors
}
from
"@/utils/requests/authenticateUser"
;
import
authenticateUser
,
{
parseAuthicationErrors
}
from
"@/utils/requests/authenticateUser"
;
import
type
{
IuserInformations
}
from
"@/utils/requests/types"
;
import
type
{
IuserInformations
}
from
"@/utils/requests/types"
;
import
getUserInformations
from
"@/utils/requests/userInformations"
;
import
getUserInformations
,
{
parseUserInformationsErrors
,
}
from
"@/utils/requests/userInformations"
;
import
ErrorModal
from
"@components/modals/ErrorModal"
;
import
ErrorModal
from
"@components/modals/ErrorModal"
;
import
{
LOG
}
from
"@logger"
;
import
{
LOG
}
from
"@logger"
;
import
AsyncStorage
from
"@react-native-async-storage/async-storage"
;
import
AsyncStorage
from
"@react-native-async-storage/async-storage"
;
...
@@ -136,6 +138,9 @@ export const UserAuthenticationContextProvider = ({ children }: { children: Reac
...
@@ -136,6 +138,9 @@ export const UserAuthenticationContextProvider = ({ children }: { children: Reac
},
},
onError
:
(
error
)
=>
{
onError
:
(
error
)
=>
{
log
.
error
(
"userInformationsMutation"
,
error
);
log
.
error
(
"userInformationsMutation"
,
error
);
const
errorString
=
parseUserInformationsErrors
(
error
);
showModal
(<
ErrorModal
message=
{
errorString
}
/>);
clearStorages
();
},
},
});
});
...
...
src/utils/requests/userInformations.ts
View file @
a36f44c3
...
@@ -23,3 +23,18 @@ const getUserInformations = async (userAccessToken: string) => {
...
@@ -23,3 +23,18 @@ const getUserInformations = async (userAccessToken: string) => {
};
};
export
default
getUserInformations
;
export
default
getUserInformations
;
export
const
parseUserInformationsErrors
=
(
error
:
unknown
):
string
=>
{
// if (error instanceof AxiosError && error.response) {
// switch (error.response.status) {
// case 401:
// return "Wrong username or password";
// default:
// return "Unknown Error. Please try again.";
// }
// }
// if (error instanceof AxiosError && error.request) {
// return "Network error";
// }
return
"Failure to fetch user informations. Please try again."
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment