This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: initial work to add more proper error handling
In this commit I wanted to use `require` to import the `.github/ISSUE_TEMPLATE` in order to include the file contents. However, despite doing a lot of research and trying my best to figure out the METRO bundler, I cannot seem to get this working as-expected. I keep getting a "SHA-1 for file is not computed" error. According to this thread: facebook/metro#330 One potential solution is to patch metro in order to generate the SHA. However, I don't want to patch metro, that admittedly feels a bit flaky as a solution. In the next commit we'll revert the metro changes and use the GH API to get the bug report file contents instead
- Loading branch information
1 parent
6071fed
commit 425a9a6
Showing
12 changed files
with
103 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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,32 @@ | ||
import * as React from 'react'; | ||
import {ErrorMessageBox} from '@components/error-message-box'; | ||
import {View} from 'react-native'; | ||
import {SharkButton} from '@components/shark-button'; | ||
import {DynamicStyleSheet, useDynamicValue} from 'react-native-dynamic'; | ||
import {theme} from '@constants'; | ||
import {ErrorPromptProps, openGitHubIssue} from '@services'; | ||
|
||
export const ErrorPrompt = (props: ErrorPromptProps) => { | ||
const {explainMessage} = props; | ||
const styles = useDynamicValue(dynamicStyles); | ||
|
||
return ( | ||
// TODO: Create translation for buttons | ||
<View> | ||
<ErrorMessageBox message={explainMessage} /> | ||
<SharkButton | ||
style={styles.githubButton} | ||
type={'primary'} | ||
onPress={() => openGitHubIssue(props)} | ||
icon={'github'} | ||
text={'Create issue'} | ||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
const dynamicStyles = new DynamicStyleSheet({ | ||
githubButton: { | ||
backgroundColor: theme.colors.label_high_emphasis, | ||
}, | ||
}); |
This file contains 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 @@ | ||
export * from './error-prompt'; |
This file contains 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,4 @@ | ||
export const RepoConfig = { | ||
owner: 'oceanbit-dev', | ||
name: 'GitShark', | ||
}; |
This file contains 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 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './get-current-user'; | ||
export * from './get-current-user-emails'; | ||
export * from './open-issue'; |
This file contains 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,30 @@ | ||
import newGithubIssueUrl from 'new-github-issue-url'; | ||
import {Linking} from 'react-native'; | ||
import {RepoConfig} from '@constants/repo-config'; | ||
const bugReport = require('githubIssues/bug_report.md'); | ||
|
||
export interface ErrorPromptProps { | ||
// EG: "An error occured while loading staged files." | ||
explainMessage: string; | ||
// EG: undefined is not a function | ||
errorMessage: string; | ||
// EG: "_callee2$@http://localhost:8081/ind..." | ||
callStack: string; | ||
} | ||
|
||
export function openGitHubIssue(err: ErrorPromptProps) { | ||
const body = bugReport | ||
.replace( | ||
'{{Put the simple error code here}}', | ||
`**${err.explainMessage}**: ${err.errorMessage}`, | ||
) | ||
.replace('{{Put the stack trace here}}', err.callStack); | ||
|
||
const url = newGithubIssueUrl({ | ||
user: RepoConfig.owner, | ||
repo: RepoConfig.name, | ||
body, | ||
}); | ||
|
||
return Linking.openURL(url); | ||
} |
This file contains 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export const logStore = false; | ||
export const throwError = true; |
This file contains 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 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 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