-
Notifications
You must be signed in to change notification settings - Fork 3
fix(ui): show specific Bible passage error messages #203
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,7 @@ | ||
| --- | ||
| '@youversion/platform-react-hooks': patch | ||
| '@youversion/platform-core': patch | ||
| '@youversion/platform-react-ui': patch | ||
| --- | ||
|
|
||
| fix(ui): show specific Bible passage error messages |
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,60 @@ | ||
| type BibleTextError = Error & { | ||
| status?: number; | ||
| }; | ||
|
|
||
| const PASSAGE_NOT_FOUND_MESSAGE = "This passage isn't available in the selected Bible version."; | ||
| const INVALID_APP_KEY_MESSAGE = | ||
| "This Bible content couldn't be loaded because the app key is missing or invalid."; | ||
| const FORBIDDEN_MESSAGE = "This app isn't allowed to access this Bible content."; | ||
| const UNREACHABLE_SERVER_MESSAGE = | ||
| "The Bible server couldn't be reached. Check your connection and try again."; | ||
| const RATE_LIMITED_MESSAGE = | ||
| 'The Bible service is receiving too many requests right now. Please wait a moment and try again.'; | ||
| const SERVER_ERROR_MESSAGE = | ||
| 'The Bible service is having trouble right now. Please try again in a moment.'; | ||
| const GENERIC_ERROR_MESSAGE = "We couldn't load this Bible passage. Please try again."; | ||
|
|
||
| function isUnreachableServerError(message: string): boolean { | ||
| return ( | ||
| message.includes('failed to fetch') || | ||
| message.includes('networkerror') || | ||
| message.includes('network request failed') || | ||
| message.includes('load failed') || | ||
| message.includes('request timeout') | ||
| ); | ||
| } | ||
|
|
||
| export function getBibleTextErrorMessage(error: BibleTextError): string { | ||
| const status = error.status; | ||
| const message = error.message.toLowerCase(); | ||
|
|
||
| if (status === 401) { | ||
| return INVALID_APP_KEY_MESSAGE; | ||
| } | ||
|
|
||
| if (status === 403) { | ||
| return FORBIDDEN_MESSAGE; | ||
| } | ||
|
|
||
| if (status === 429) { | ||
| return RATE_LIMITED_MESSAGE; | ||
| } | ||
|
|
||
| if (status !== undefined && status >= 500) { | ||
| return SERVER_ERROR_MESSAGE; | ||
| } | ||
|
|
||
| if (status === 404 || message.includes('not found')) { | ||
| return PASSAGE_NOT_FOUND_MESSAGE; | ||
| } | ||
|
|
||
| if (typeof navigator !== 'undefined' && navigator.onLine === false) { | ||
| return UNREACHABLE_SERVER_MESSAGE; | ||
| } | ||
|
|
||
| if (isUnreachableServerError(message)) { | ||
| return UNREACHABLE_SERVER_MESSAGE; | ||
| } | ||
|
|
||
| return GENERIC_ERROR_MESSAGE; | ||
| } |
Oops, something went wrong.
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.