Raise error when stat is not 'OK' in Stock.fetch()
ianlini opened this issue · comments
Ian Lin commented
In TWSEFetcher.fetch()
, we currently catch the JSONDecodeError
(or ValueError
in Python 2) and let the return value to be:
{
'stat': '',
'data': []
}
stat
may also be other values return by TWSE / TPEX, and we don't check the stat
in Stock.fetch()
.
This is bad because when using Stock
, users won't know what happens unless they look into the Stock.raw_data
.
I propose 2 solutions:
- raise error when 'stat' is not 'OK' in
Stock.fetch()
Stock.fetch()
gives a better return value to let users know what happens
I prefer 1. because Stock.fetch()
should be a high-level function that is always successful, so users should always deal with the non-OK stat.