From 9d89d618fe793d2a2afd5132bc6a726c0a684217 Mon Sep 17 00:00:00 2001 From: 0xean <0xean.eth@gmail.com> Date: Fri, 26 Jul 2024 10:23:22 -0400 Subject: [PATCH 1/2] fix: adds error message to logs --- cli/src/index.ts | 1 - cli/src/ipfs.ts | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cli/src/index.ts b/cli/src/index.ts index 50200ae..f1a662c 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -22,7 +22,6 @@ const processEpoch = async () => { const month = MONTHS[new Date(metadata.epochStartTimestamp).getUTCMonth()] info(`Processing rFOX Epoch #${metadata.epoch} for ${month} distribution.`) - const now = Date.now() if (metadata.epochEndTimestamp > now) { const daysRemaining = Math.round((metadata.epochEndTimestamp - now) / (24 * 60 * 60 * 1000)) diff --git a/cli/src/ipfs.ts b/cli/src/ipfs.ts index e62890f..45d642a 100644 --- a/cli/src/ipfs.ts +++ b/cli/src/ipfs.ts @@ -132,8 +132,8 @@ export class IPFS { error(`The contents of IPFS hash (${hash}) are not valid epoch contents, exiting.`) process.exit(1) } - } catch { - error(`Failed to get content of IPFS hash (${hash}), exiting.`) + } catch (err) { + error(`Failed to get content of IPFS hash (${hash}), exiting. ${err}`) process.exit(1) } } @@ -290,8 +290,8 @@ export class IPFS { error(`The contents of IPFS hash (${hash}) are not valid metadata contents, exiting.`) process.exit(1) - } catch { - error(`Failed to get content of IPFS hash (${hash}), exiting.`) + } catch (err) { + error(`Failed to get content of IPFS hash (${hash}), exiting. ${err}`) process.exit(1) } } From 4f7ebe7006506f4b6ab192ab3293e547f26383a0 Mon Sep 17 00:00:00 2001 From: kaladinlight <35275952+kaladinlight@users.noreply.github.com> Date: Fri, 26 Jul 2024 09:10:35 -0600 Subject: [PATCH 2/2] type check update --- cli/src/index.ts | 1 + cli/src/ipfs.ts | 20 +++++++++++++++++--- cli/src/wallet.ts | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cli/src/index.ts b/cli/src/index.ts index f1a662c..50200ae 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -22,6 +22,7 @@ const processEpoch = async () => { const month = MONTHS[new Date(metadata.epochStartTimestamp).getUTCMonth()] info(`Processing rFOX Epoch #${metadata.epoch} for ${month} distribution.`) + const now = Date.now() if (metadata.epochEndTimestamp > now) { const daysRemaining = Math.round((metadata.epochEndTimestamp - now) / (24 * 60 * 60 * 1000)) diff --git a/cli/src/ipfs.ts b/cli/src/ipfs.ts index 45d642a..4c5c4e1 100644 --- a/cli/src/ipfs.ts +++ b/cli/src/ipfs.ts @@ -1,6 +1,6 @@ import * as prompts from '@inquirer/prompts' import PinataClient from '@pinata/sdk' -import axios from 'axios' +import axios, { isAxiosError } from 'axios' import BigNumber from 'bignumber.js' import { error, info } from './logging' import { Epoch, RFOXMetadata, RewardDistribution } from './types' @@ -133,7 +133,14 @@ export class IPFS { process.exit(1) } } catch (err) { - error(`Failed to get content of IPFS hash (${hash}), exiting. ${err}`) + if (isAxiosError(err)) { + error( + `Failed to get content of IPFS hash (${hash}): ${err.request?.data?.message || err.response?.data?.message || err.message}, exiting.`, + ) + } else { + error(`Failed to get content of IPFS hash (${hash}): ${err}, exiting.`) + } + process.exit(1) } } @@ -291,7 +298,14 @@ export class IPFS { error(`The contents of IPFS hash (${hash}) are not valid metadata contents, exiting.`) process.exit(1) } catch (err) { - error(`Failed to get content of IPFS hash (${hash}), exiting. ${err}`) + if (isAxiosError(err)) { + error( + `Failed to get content of IPFS hash (${hash}): ${err.request?.data || err.response?.data || err.message}, exiting.`, + ) + } else { + error(`Failed to get content of IPFS hash (${hash}): ${err}, exiting.`) + } + process.exit(1) } } diff --git a/cli/src/wallet.ts b/cli/src/wallet.ts index a04aea1..0469166 100644 --- a/cli/src/wallet.ts +++ b/cli/src/wallet.ts @@ -135,7 +135,7 @@ export class Wallet { resolve && resolve() return true - } catch (err: any) { + } catch (err) { spinner?.fail() if (isAxiosError(err)) {