Skip to content

Commit 765c82b

Browse files
committed
Modified comments and improved the error thrown by getTransactionWithRetry
1 parent 8794e52 commit 765c82b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tool/pmt-builder-utils.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ const getTransactionWithRetry = async (transactionsClient, txId, retries = 0) =>
7474
try {
7575
return await transactionsClient.getTxHex({txid: txId});
7676
} catch (error) {
77-
// mempool.js might wrap the error, so we check for common indicators of 429
77+
// mempool.js might wrap the error, so we check for common indicators of too many requests error code
7878
const isRateLimitError = error.response && error.response.status === TOO_MANY_REQUESTS_ERROR_CODE;
7979

80-
// Sometimes the error message might contain clues if status is not directly 429
80+
// Sometimes the error message might contain clues if status code is not directly 429
8181
const isMempoolSpecificRateLimit = error.message && error.message.includes('Too Many Requests');
8282

8383
if ((isRateLimitError || isMempoolSpecificRateLimit) && retries < MAX_RETRIES) {
@@ -87,9 +87,7 @@ const getTransactionWithRetry = async (transactionsClient, txId, retries = 0) =>
8787
return getTransactionWithRetry(transactionsClient, txId, retries + 1);
8888
}
8989

90-
throw new Error(`Failed to fetch transaction details for txId: ${txId} after ${retries} retries. Error: ${error.message}`,
91-
{ cause: error }
92-
);
90+
throw new Error(`Failed to fetch transaction details for txId: ${txId} after ${retries} retries. Error: ${error.message}`);
9391
}
9492
};
9593

0 commit comments

Comments
 (0)