Skip to content
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

add exposure to context, prevent unhandled exception #963

Merged
merged 2 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ExposureContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ const ExposureProvider: FunctionComponent = ({ children }) => {
)
getLastExposureDetectionDate()

detectExposures()

// Chaff subscription
const chaffSubscription = NativeModule.subscribeToChaffRequestEvents(() => {
sendChaffRequest()
Expand Down
5 changes: 4 additions & 1 deletion src/gaen/nativeModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ type DetectExposuresError =
| "NotEnabled"
| "NotAuthorized"
| "DataInaccessible"
| "EUNSPECIFIED"

export type DetectExposuresResponse =
| DetectExposuresResponseSuccess
Expand Down Expand Up @@ -206,6 +207,8 @@ export const detectExposures = async (): Promise<DetectExposuresResponse> => {
return { kind: "failure", error: "NotAuthorized" }
case "Unknown":
return { kind: "failure", error: "DataInaccessible" }
case "EUNSPECIFIED":
return { kind: "failure", error: "Unknown" }
default:
Logger.error("Unhandled Error in detectExposures", { e })
return { kind: "failure", error: "Unknown" }
Expand All @@ -229,7 +232,7 @@ export const getExposureKeys = async (): Promise<ExposureKey[]> => {
const exposureKeys = rawKeys.map(toExposureKey)
return exposureKeys
} else {
Logger.error("Invalid expousre keys from native layer", { rawKeys })
Logger.error("Invalid exposure keys from native layer", { rawKeys })
throw new Error("Invalid exposure keys from native layer")
}
}
Expand Down