Skip to content

Commit 2ad26bb

Browse files
committed
Fix error display in RampSelectOptionScene
This happens because `useRampQuotes` calls `runWithTimeout` for 10 seconds. If that timeout triggers, we show an error card in place of the payment method. Fix to increase the delay, only ever show one error card, and also notify the user to check their network connection.
1 parent 5196784 commit 2ad26bb

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

src/components/scenes/RampSelectOptionScene.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ export const RampSelectOptionScene: React.FC<Props> = (props: Props) => {
154154
? lstrings.trade_option_buy_title
155155
: lstrings.trade_option_sell_title
156156

157+
// Only show a single non-fiat provider error when there are no quotes
158+
const nonFiatErrors = React.useMemo(() => {
159+
return failedQuotes.filter(q => !(q.error instanceof FiatProviderError))
160+
}, [failedQuotes])
161+
157162
return (
158163
<SceneWrapper scroll hasTabs>
159164
<SceneContainer headerTitle={headerTitle}>
@@ -199,22 +204,12 @@ export const RampSelectOptionScene: React.FC<Props> = (props: Props) => {
199204
/>
200205
)
201206
)}
202-
{failedQuotes.map(quoteError => {
203-
const error = quoteError.error
204-
if (error instanceof FiatProviderError) {
205-
// Ignore known FiatProviderErrors
206-
return null
207-
}
208-
209-
// We should communicate all unknown errors to the user for
210-
// reporting purposes.
211-
return (
212-
<ErrorCard
213-
key={`error-${quoteError.pluginId}`}
214-
error={quoteError.error}
215-
/>
216-
)
217-
})}
207+
{allQuotes.length === 0 && nonFiatErrors.length > 0 ? (
208+
<ErrorCard
209+
key="ramp-quotes-error"
210+
error={nonFiatErrors[0].error}
211+
/>
212+
) : null}
218213
</>
219214
)}
220215
</SceneContainer>

src/hooks/useRampQuotes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const useRampQuotes = ({
5858
try {
5959
const quotes = await runWithTimeout(
6060
plugin.fetchQuotes(rampQuoteRequest),
61-
10000
61+
15000
6262
)
6363
return { ok: true, value: quotes }
6464
} catch (error) {

src/locales/en_US.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ const strings = {
13641364
error_unexpected_title: 'Unexpected Error',
13651365
error_kyc_required_s: 'KYC required: %s',
13661366
error_generic_message:
1367-
'An unexpected error occurred. Please try again later.',
1367+
'An unexpected error occurred. Please check your network connection and try again later.',
13681368

13691369
export_transaction_date_range: 'Date Range',
13701370
export_transaction_export_type: 'Export Type',

src/locales/strings/enUS.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@
10701070
"error_boundary_help_button": "Help Closing App",
10711071
"error_unexpected_title": "Unexpected Error",
10721072
"error_kyc_required_s": "KYC required: %s",
1073-
"error_generic_message": "An unexpected error occurred. Please try again later.",
1073+
"error_generic_message": "An unexpected error occurred. Please check your network connection and try again later.",
10741074
"export_transaction_date_range": "Date Range",
10751075
"export_transaction_export_type": "Export Type",
10761076
"export_transaction_this_month": "This Month",

0 commit comments

Comments
 (0)