@@ -29,6 +29,10 @@ export default Engine =>
29
29
proposal . contractType === contractType &&
30
30
proposal . purchaseReference === this . getPurchaseReference ( )
31
31
) {
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.
32
36
if ( proposal . error ) {
33
37
const { error } = proposal . error . error ;
34
38
const { code, message } = error ;
@@ -64,7 +68,23 @@ export default Engine =>
64
68
requestProposals ( ) {
65
69
Promise . all (
66
70
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
+ )
68
88
)
69
89
) . catch ( e => this . $scope . observer . emit ( 'Error' , e ) ) ;
70
90
}
0 commit comments