Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 9826f07

Browse files
committed
Handle ContractBuyValidationError
1 parent c5dc584 commit 9826f07

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/botPage/bot/TradeEngine/Proposal.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export default Engine =>
2929
proposal.contractType === contractType &&
3030
proposal.purchaseReference === this.getPurchaseReference()
3131
) {
32+
// Below happens when a user has had one of the proposals return
33+
// with a ContractBuyValidationError. We allow the logic to continue
34+
// to here cause the opposite proposal may still be valid. Only once
35+
// they attempt to purchase the errored proposal we will intervene.
3236
if (proposal.error) {
3337
const { error } = proposal.error.error;
3438
const { code, message } = error;
@@ -64,7 +68,23 @@ export default Engine =>
6468
requestProposals() {
6569
Promise.all(
6670
this.proposalTemplates.map(proposal =>
67-
doUntilDone(() => this.api.subscribeToPriceForContractProposal(proposal))
71+
doUntilDone(() =>
72+
this.api.subscribeToPriceForContractProposal(proposal).catch(error => {
73+
// We intercept ContractBuyValidationError as user may have specified
74+
// e.g. a DIGITUNDER 0 or DIGITOVER 9, while one proposal may be invalid
75+
// the other is valid. We will error on Purchase rather than here.
76+
if (error && error.name === 'ContractBuyValidationError') {
77+
this.data.proposals.push({
78+
...error.error.echo_req,
79+
...error.error.echo_req.passthrough,
80+
error,
81+
});
82+
return null;
83+
}
84+
85+
throw error;
86+
})
87+
)
6888
)
6989
).catch(e => this.$scope.observer.emit('Error', e));
7090
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy