Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adds error message to logs #84

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions cli/src/ipfs.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -132,8 +132,15 @@ 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) {
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)
}
}
Expand Down Expand Up @@ -290,8 +297,15 @@ 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) {
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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class Wallet {
resolve && resolve()

return true
} catch (err: any) {
} catch (err) {
spinner?.fail()

if (isAxiosError(err)) {
Expand Down