Skip to content

Commit

Permalink
Merge pull request #84 from shapeshift/fix/error-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladinlight authored Jul 26, 2024
2 parents cd76ea8 + 4f7ebe7 commit f57386e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
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

0 comments on commit f57386e

Please sign in to comment.