Skip to content

Commit 8df395c

Browse files
authored
Merge pull request #836 from PayButton/feat/better-error-message-for-missing-prices
feat: better error message for missing prices
2 parents 93e478d + e915eae commit 8df395c

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const RESPONSE_MESSAGES = {
5050
NETWORK_SLUG_NOT_PROVIDED_400: { statusCode: 400, message: "'networkSlug' not provided." },
5151
QUOTE_SLUG_NOT_PROVIDED_400: { statusCode: 400, message: "'quoteSlug' not provided." },
5252
NO_CURRENT_PRICES_FOUND_404: { statusCode: 404, message: 'Current prices not found.' },
53-
NO_PRICES_FOUND_404: { statusCode: 404, message: 'Prices not found.' },
53+
NO_PRICES_FOUND_404: (networkId: number, timestamp: number) => { return { statusCode: 404, message: `Prices not found for ${NETWORK_TICKERS_FROM_ID[networkId]} at timestamp ${timestamp}.` } },
5454
INVALID_QUOTE_SLUG_400: { statusCode: 400, message: 'Invalid quote slug.' },
5555
INVALID_TICKER_400: { statusCode: 400, message: 'Invalid ticker.' },
5656
MISSING_BLOCKCHAIN_CLIENT_400: { statusCode: 400, message: 'There is no blockchain client chosen for this network.' },

services/priceService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export async function fetchPricesForNetworkAndTimestamp (networkId: number, time
242242
if (attempt < PRICE_API_MAX_RETRIES) {
243243
return await fetchPricesForNetworkAndTimestamp(networkId, timestamp, prisma, attempt + 1)
244244
}
245-
throw new Error(RESPONSE_MESSAGES.NO_PRICES_FOUND_404.message)
245+
throw new Error(RESPONSE_MESSAGES.NO_PRICES_FOUND_404(networkId, timestamp).message)
246246
}
247247
return {
248248
cad: cadPrice,

0 commit comments

Comments
 (0)