Skip to content

Commit 3c3bd52

Browse files
committed
chore: extract message into const
1 parent 271e8fe commit 3c3bd52

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/utils/errors.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const USER_REJECTED_REGEX = new RegExp(
2929
'mi',
3030
);
3131
export const AMOUNT_IN_TOO_SMALL = new RegExp('AmountInTooSmall', 'm');
32+
const INSUFFICIENT_FUNDS_FOR_GAS_ERROR =
33+
'Insufficient funds for network fees. Please add more funds and try again';
3234

3335
export function interpretTransferError(
3436
e: any,
@@ -53,8 +55,7 @@ export function interpretTransferError(
5355
uiErrorMessage = 'Transfer timed out, please try again';
5456
internalErrorCode = ERR_TIMEOUT;
5557
} else if (InsufficientFundsForGasError.MESSAGE_REGEX.test(e?.message)) {
56-
uiErrorMessage =
57-
'Insufficient funds for network fees, please add more funds and try again';
58+
uiErrorMessage = INSUFFICIENT_FUNDS_FOR_GAS_ERROR;
5859
internalErrorCode = ERR_INSUFFICIENT_GAS;
5960
} else if (USER_REJECTED_REGEX.test(e?.message)) {
6061
uiErrorMessage = 'Transfer rejected in wallet, please try again';
@@ -88,10 +89,9 @@ export function interpretTransferError(
8889
const gasSymbol = getTokenSymbol(gasToken);
8990
const chainName = chainDisplayName(gasChain);
9091
const chainSuffix = chainName ? ` on ${chainName}` : '';
91-
uiErrorMessage = `Insufficient ${gasSymbol} for fees${chainSuffix}, please add more ${gasSymbol} and try again`;
92+
uiErrorMessage = `Insufficient ${gasSymbol} for fees${chainSuffix}. Please add more ${gasSymbol} and try again`;
9293
} catch {
93-
uiErrorMessage =
94-
'Insufficient funds for network fees, please add more funds and try again';
94+
uiErrorMessage = INSUFFICIENT_FUNDS_FOR_GAS_ERROR;
9595
}
9696
internalErrorCode = ERR_INSUFFICIENT_GAS;
9797
}

0 commit comments

Comments
 (0)