Skip to content

Commit

Permalink
fix: handle ledger errors in client errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nicole-obrien committed May 18, 2023
1 parent 7816c44 commit 0a0f874
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/shared/lib/core/error/handlers/handleError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { handleWalletRsError } from './walletRs'
export function handleError(err: IError, resetConfirmationPropsOnDenial = true): void {
const _activeProfile = get(activeProfile)
if (Object.values(WalletRsError).includes(err?.type as WalletRsError)) {
handleWalletRsError(err)
handleWalletRsError(err, resetConfirmationPropsOnDenial)
} else if (_activeProfile.type === ProfileType.Ledger) {
handleLedgerError(err, resetConfirmationPropsOnDenial)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
handleNoOutputsToConsolidateError,
} from './subhandlers'

export function handleWalletRsError(error: IError): void {
export function handleWalletRsError(error: IError, resetConfirmationPropsOnDenial = true): void {
if (error?.type) {
switch (error.type) {
case WalletRsError.Client.valueOf():
handleClientError(error)
handleClientError(error, resetConfirmationPropsOnDenial)
break
case WalletRsError.InsufficientFunds.valueOf():
handleInsufficientFundsError(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { ClientError, WalletRsError } from '../../../enums'
import { IError } from '../../../interfaces'
import { logAndNotifyError } from '../../../actions'
import { handleGenericError } from '../../handleGenericError'
import { LedgerError, handleLedgerError } from '@core/ledger'

export function handleClientError(error: IError): void {
export function handleClientError(error: IError, resetConfirmationPropsOnDenial = true): void {
const errorMessage = error?.error
let errorKey
if (errorMessage) {
Expand All @@ -18,6 +19,9 @@ export function handleClientError(error: IError): void {
case CLIENT_ERROR_REGEXES[ClientError.InsufficientAmount].test(errorMessage):
errorKey = ClientError.InsufficientAmount
break
case Object.values(LedgerError).some((ledgerError) => errorMessage.includes(ledgerError)):
handleLedgerError(error, resetConfirmationPropsOnDenial)
return
}
if (errorKey) {
const errorObject = WALLET_RS_ERROR_PARAMETERS?.[WalletRsError.Client]?.[errorKey]
Expand Down

0 comments on commit 0a0f874

Please sign in to comment.