TheOtherDavid / CoinCheck

A simple app that checks a crypto coin price and sends an SMS alert if there has been a big move recently.
1 stars 0 forks source link

Fresh DB produces index out of bounds errors #13

Closed TheOtherDavid closed 3 years ago

TheOtherDavid commented 3 years ago

The code references rows[0] and rows[1], after the getPrices call for the last six hours. Normally this isn't a big deal, but if there aren't any prices returned, it'll throw an index out of bounds error. We should do an If size(rows)>1 or something before calling it.

TheOtherDavid commented 3 years ago

This is closed by PR #15, kind of by accident, but this means we won't be calling rows[1] manually. Since we ALWAYS save a price first, the "get last six hours" call will ALWAYS return at least one item, so rows[0] is not an issue.