Skip to content

Commit

Permalink
feat: catch error messages in sagas for nfts
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteubs-bc committed May 2, 2022
1 parent 3a2dea0 commit 1e1bd4e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type TurnOffOn = 'TURN_OFF' | 'TURN_ON'

type SaleType = 'FIXED_PRICE' | 'TIME_AUCTION'

type Outcome = 'DROP-OFF' | 'FAILED' | 'SUCCESS'
type Type = 'DROP-OFF' | 'FAILED' | 'SUCCESS'

type AcceptedAccountsAction = {
key: Events.NFT_ACCEPTED_ACCOUNTS
Expand All @@ -61,7 +61,8 @@ type AcceptedAccountsAction = {
type AcceptOfferSuccessFailAction = {
key: Events.NFT_ACCEPT_OFFER_SUCCESS_FAIL
properties: {
outcome: Outcome
error_message?: string
type: Type
}
}

Expand Down Expand Up @@ -104,21 +105,24 @@ type BuyNowClickedAction = {
type BuySuccessFailAction = {
key: Events.NFT_BUY_SUCCESS_FAIL
properties: {
outcome: Outcome
error_message?: string
type: Type
}
}

type CancelListingSuccessFailAction = {
key: Events.NFT_CANCEL_LISTING_SUCCESS_FAIL
properties: {
outcome: Outcome
error_message?: string
type: Type
}
}

type CancelOfferSuccessFailAction = {
key: Events.NFT_CANCEL_OFFER_SUCCESS_FAIL
properties: {
outcome: Outcome
error_message?: string
type: Type
}
}

Expand Down Expand Up @@ -203,7 +207,8 @@ type LeftMenuExpandedAction = {
type ListingSuccessFailAction = {
key: Events.NFT_LISTING_SUCCESS_FAIL
properties: {
outcome: Outcome
error_message?: string
type: Type
}
}

Expand Down Expand Up @@ -243,7 +248,8 @@ type OfferWithClickedAction = {
type OfferSuccessFailAction = {
key: Events.NFT_OFFER_SUCCESS_FAIL
properties: {
outcome: Outcome
error_message?: string
type: Type
}
}

Expand Down Expand Up @@ -281,14 +287,16 @@ type SellItemClickedAction = {
type SellItemSuccessFailAction = {
key: Events.NFT_SELL_ITEM_SUCCESS_FAIL
properties: {
outcome: Outcome
error_message?: string
type: Type
}
}

type SendSuccessFailAction = {
key: Events.NFT_SEND_SUCCESS_FAIL
properties: {
outcome: Outcome
error_message?: string
type: Type
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,21 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_ACCEPT_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
type: 'SUCCESS'
}
})
)
} catch (e) {
let error = errorHandler(e)
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_ACCEPT_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
error_message: error,
type: 'FAILED'
}
})
)
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to accept this offer.'
yield put(actions.logs.logErrorMessage(error))
Expand Down Expand Up @@ -373,21 +374,22 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
type: 'SUCCESS'
}
})
)
} catch (e) {
let error = errorHandler(e)
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
error_message: error,
type: 'FAILED'
}
})
)
yield put(A.setOrderFlowStep({ step: NftOrderStepEnum.MAKE_OFFER }))
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to create this offer.'
yield put(actions.logs.logErrorMessage(error))
Expand All @@ -414,7 +416,7 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_BUY_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
type: 'SUCCESS'
}
})
)
Expand All @@ -423,18 +425,20 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_SELL_ITEM_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
type: 'SUCCESS'
}
})
)
}
} catch (e) {
let error = errorHandler(e)
if (!action.payload.sell) {
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_BUY_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
error_message: error,
type: 'FAILED'
}
})
)
Expand All @@ -443,12 +447,12 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_SELL_ITEM_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
error_message: error,
type: 'FAILED'
}
})
)
}
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to create this order.'
yield put(actions.logs.logErrorMessage(error))
Expand Down Expand Up @@ -485,20 +489,21 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_LISTING_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
type: 'SUCCESS'
}
})
)
} catch (e) {
let error = errorHandler(e)
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_LISTING_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
error_message: error,
type: 'FAILED'
}
})
)
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to sell this asset.'
yield put(actions.logs.logErrorMessage(error))
Expand All @@ -524,20 +529,21 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_LISTING_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
type: 'SUCCESS'
}
})
)
} catch (e) {
let error = errorHandler(e)
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_SEND_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
error_message: error,
type: 'FAILED'
}
})
)
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to transfer this asset.'
yield put(actions.logs.logErrorMessage(error))
Expand All @@ -559,20 +565,21 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_CANCEL_LISTING_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
type: 'SUCCESS'
}
})
)
} catch (e) {
let error = errorHandler(e)
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_CANCEL_LISTING_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
error_message: error,
type: 'FAILED'
}
})
)
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to cancel this listing.'
yield put(actions.logs.logErrorMessage(error))
Expand All @@ -598,20 +605,21 @@ export default ({ api }: { api: APIType }) => {
actions.analytics.trackEvent({
key: Analytics.NFT_CANCEL_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'SUCCESS'
type: 'SUCCESS'
}
})
)
} catch (e) {
let error = errorHandler(e)
yield put(
actions.analytics.trackEvent({
key: Analytics.NFT_CANCEL_OFFER_SUCCESS_FAIL,
properties: {
outcome: 'FAILED'
error_message: error,
type: 'FAILED'
}
})
)
let error = errorHandler(e)
if (error.includes(INSUFFICIENT_FUNDS))
error = 'You do not have enough funds to cancel this offer.'
yield put(actions.alerts.displayError(error))
Expand Down

0 comments on commit 1e1bd4e

Please sign in to comment.