@cross-nft-marketplace/auction-house-nft-hooks
Version:
Generic react hooks for fetching cross-nft-marketplace auctions, nfts, and data on arbitary 721s. Powers nft-components.
20 lines (19 loc) • 804 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.onErrorRetry = exports.NotFoundError = void 0;
class NotFoundError extends Error {
}
exports.NotFoundError = NotFoundError;
const onErrorRetry = (err, _, swrConfiguration, revalidate, revalidateOpts) => {
if (err instanceof NotFoundError) {
// Don't retry for 404 records
return;
}
let errorRetryCount = swrConfiguration.errorRetryCount || 5;
let errorRetryInterval = swrConfiguration.errorRetryInterval || 5000;
if (revalidateOpts.retryCount && revalidateOpts.retryCount <= errorRetryCount) {
// Retry with error other than not found.
setTimeout(() => revalidate(revalidateOpts), errorRetryInterval);
}
};
exports.onErrorRetry = onErrorRetry;