-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
428f873
commit 7d0d128
Showing
7 changed files
with
69 additions
and
12 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
12 changes: 9 additions & 3 deletions
12
packages/mobile/src/components/ui/Alert/ErrorNotification.tsx
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,14 +1,20 @@ | ||
import { useEffect } from 'react'; | ||
import { useErrors } from '../../../hooks/errors/useErrors'; | ||
|
||
export const ErrorNotification = ({ error }: { error: Error | unknown }) => { | ||
export const ErrorNotification = ({ | ||
error, | ||
onlyLogging, | ||
}: { | ||
error: Error | unknown; | ||
onlyLogging?: boolean; | ||
}) => { | ||
const addError = useErrors().add; | ||
|
||
useEffect(() => { | ||
if (error) { | ||
addError(error); | ||
addError(error, undefined, undefined, onlyLogging); | ||
} | ||
}, [addError, error]); | ||
}, [addError, error, onlyLogging]); | ||
|
||
return <></>; | ||
}; |
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
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,13 +1,19 @@ | ||
import { appendFile, CachesDirectoryPath, exists, writeFile } from 'react-native-fs'; | ||
import { Error } from '../../hooks/errors/useErrors'; | ||
|
||
const fileName = 'homebase-id-app-logs.txt'; | ||
const path = `${CachesDirectoryPath}/homebase-id-app-logs.txt`; | ||
|
||
export async function addLogs(error: Error) { | ||
const path = `${CachesDirectoryPath}/${fileName}`; | ||
const err = `${new Date().toISOString()}: ${error.title} - ${error.message}\n Details: ${JSON.stringify(error.details)}\n\n`; | ||
if (!(await exists(path))) { | ||
return writeFile(path, err); | ||
} | ||
return appendFile(path, err); | ||
} | ||
|
||
export async function getLogs() { | ||
if (await exists(path)) { | ||
return `file://${path}`; | ||
} | ||
return; | ||
} |