Skip to content

Commit

Permalink
Ignore user cancel error in DiscoverReaderScreen page (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lin-bbpos authored Oct 9, 2024
1 parent cbe7199 commit 08df330
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions dev-app/src/screens/DiscoverReadersScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ export default function DiscoverReadersScreen() {
} = useStripeTerminal({
onFinishDiscoveringReaders: (finishError) => {
if (finishError) {
console.error(
'Discover readers error',
`${finishError.code}, ${finishError.message}`
);
if (shouldShowDiscoverError(finishError)) {
console.error(
'Discover readers error',
`${finishError.code}, ${finishError.message}`
);
}
if (navigation.canGoBack()) {
navigation.goBack();
}
Expand Down Expand Up @@ -165,7 +167,9 @@ export default function DiscoverReadersScreen() {

if (discoverReadersError) {
const { code, message } = discoverReadersError;
Alert.alert('Discover readers error: ', `${code}, ${message}`);
if (shouldShowDiscoverError(discoverReadersError)) {
Alert.alert('Discover readers error: ', `${code}, ${message}`);
}
if (navigation.canGoBack()) {
navigation.goBack();
}
Expand Down Expand Up @@ -535,3 +539,7 @@ function mapToPlanDisplayName(plan: string) {
return '';
}
}

function shouldShowDiscoverError(error: StripeError) {
return error.code.toString() != 'USER_ERROR.CANCELED';
}

0 comments on commit 08df330

Please sign in to comment.