-
Notifications
You must be signed in to change notification settings - Fork 0
Error handling #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Error handling #18
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
302edb1
parents translate, components receive plain strings
a-elkhiraooui-ciscode 0258a6e
1.0.3
a-elkhiraooui-ciscode a62f9b7
tested in local, bug fixed
a-elkhiraooui-ciscode 3bd91d4
1.0.4
a-elkhiraooui-ciscode 68a2b0a
Merge branch 'master' of https://github.com/CISCODE-MA/AuthKit-UI int…
a-elkhiraooui-ciscode 91f6973
Merge branch 'master' of https://github.com/CISCODE-MA/AuthKit-UI int…
a-elkhiraooui-ciscode b13ea31
forgot and reset password done
a-elkhiraooui-ciscode c20676e
1.0.6
a-elkhiraooui-ciscode 3fe9bc8
verify email page done
a-elkhiraooui-ciscode 976a57f
Merge branch 'master' of https://github.com/CISCODE-MA/AuthKit-UI int…
a-elkhiraooui-ciscode c872138
merged
a-elkhiraooui-ciscode d675672
1.0.10
a-elkhiraooui-ciscode ea372ac
Merge branch 'develop' of https://github.com/CISCODE-MA/AuthKit-UI in…
a-elkhiraooui-ciscode 1f17429
updated endpoints
a-elkhiraooui-ciscode 8844b2d
endpoints fixed
a-elkhiraooui-ciscode 1c2ac98
show profile updated to match new response
a-elkhiraooui-ciscode d0653e2
added unit tests
a-elkhiraooui-ciscode 463c1a5
added error handling to forgot password, reset password and signin/up…
a-elkhiraooui-ciscode f062b2a
Merge branch 'master' of https://github.com/CISCODE-MA/AuthKit-UI int…
a-elkhiraooui-ciscode f341eb4
1.0.13
a-elkhiraooui-ciscode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import type { AxiosError } from 'axios'; | ||
|
|
||
| type ErrorResponse = { | ||
| ok?: boolean; | ||
| code?: string; | ||
| message?: string; | ||
| requestId?: string; | ||
| path?: string; | ||
| details?: { | ||
| message?: string; | ||
| error?: string; | ||
| statusCode?: number; | ||
| }; | ||
| }; | ||
|
|
||
| function isAxiosError(err: unknown): err is AxiosError { | ||
| return !!(err as any)?.isAxiosError; | ||
Zaiidmo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * Extract a user-facing error message from common backend/HTTP shapes. | ||
| * Preference order: | ||
| * 1) response.data.details.message | ||
| * 2) response.data.message | ||
| * 3) response.data.details.error | ||
| * 4) err.message | ||
| * 5) generic fallback | ||
| */ | ||
| export function extractHttpErrorMessage(err: unknown): string { | ||
| try { | ||
| if (typeof err === 'string') return err; | ||
|
|
||
| if (isAxiosError(err)) { | ||
| const data = err.response?.data as ErrorResponse | undefined; | ||
| const fromResponse = | ||
| data?.details?.message?.toString()?.trim() || | ||
| data?.message?.toString()?.trim() || | ||
| data?.details?.error?.toString()?.trim(); | ||
| if (fromResponse) return fromResponse; | ||
| if (err.message) return err.message; | ||
| } | ||
|
|
||
| if (err instanceof Error && err.message) return err.message; | ||
| } catch {/* ignore parsing issues */} | ||
|
|
||
| return 'An unexpected error occurred'; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.