rodolfobandeira / iex-cpp-client

IEX Finance API C++ Client. Stock Tracking, Companies Information, Financial Reports, Dividends, Statistics, Etc
MIT License
7 stars 4 forks source link

Add error handler when stock symbol is invalid #20

Open rodolfobandeira opened 6 years ago

rodolfobandeira commented 6 years ago
./main STOCK_SYMBOL_THAT_DOESNT_EXIST -d
Error from reader: * Line 1, Column 1
  Syntax error: value, object or array expected.
terminate called after throwing an instance of 'Json::RuntimeError'
  what():  * Line 1, Column 1
  Syntax error: value, object or array expected.

Aborted (core dumped)
Chudleyj commented 6 years ago

Hello, I believe you have already seen my IEX C++ API. I recently wrote this for mine (I have not pushed it yet as I am still implementing it fully), here is the code for the symbol checking. If you would like to use it feel free, I like what you're doing with this.

https://pastebin.com/uvBBM1R6

You'll need to include Algorithm for std::find()

Chudleyj commented 6 years ago

Update, that pastebin link is now outdated. I added boost::to_upper(symbol) to it, as I realized all symbols returned from IEX are uppercase. I've also finished adding this to my project and have pushed the changes. See latest commit for how to resolve this issue here: https://github.com/Chudleyj/IEX_CPP_API

Chudleyj commented 6 years ago

Created pull request, however the functions are not ever called, so the symbols are not being checked yet.

rodolfobandeira commented 6 years ago

Hi @Chudleyj ! I shared some thoughts on your PR. Thank you very much!