问题
I have a Pharo extension that adds promises to Pharo Smalltalk. I then use the promise extension to do a bank transfer with the following bank application.An account contacts the bank in order to transfer money to another account. This code fails with the error SubscriptOutOfBounds:5. I looked at Recursive method in pharo produces #SubscriptOutOfBounds:8. It talks about array bounds but I have no clue where I could be using arrays in my implementation unless the stack does.The debugger says something about arrays but at the moment it is too cryptic for me.The promises work just fine with other examples but fail for this particular example. And it appears the error occurs due to the commented out code in Account>>transfer:to:
Below is Account>>transfer:to:
transfer: amount to: account
| bank promise|
bank := Bank new.
(availability > (lowerLimit + amount)) ifTrue: [ availability := availability - amount.
promise := [ bank transfer: amount from: self to: account ]promiseValue.
"promise
then: [ :respose |
respose
ifTrue: [ self reduceBalance: amount ] ]
catch: [ :error | ^error ] "]
ifFalse: [ ^ self ].
And this is Bank >> transfer:amount:from: to:
transfer: amount from: anAccount1 to: anAccount2
|transfered|
transfered := false.
(anAccount1 availableBalance < anAccount1 lowerLimit + amount)
ifTrue:
[self error: 'Account lower Limit reached', (anAccount1 lowerLimit) printString ]
ifFalse:
[ self deposit: amount to: anAccount2. transfered := true ].
^transfered
What could be the cause of this error?
来源:https://stackoverflow.com/questions/50086700/pharo-subscriptoutofbounds5-error