Closed cshields1 closed 1 year ago
Hi @cshields1, the library throws an error if IEX returns anything but a 200, [here].(https://github.com/tyrauber/stock_quote/blob/master/lib/stock_quote/stock.rb#L67)
raise response.body unless response.code == 200
One way to handle this, is wrap the query in a rescue and handle the error.
@stock = StockQuote::Stock.quote(param[:symbol])
rescue => e
# Handle error here
Currently trying to prevent junky user input on a search form. If I search for a symbol that doesn't exist, IEX returns a 404 and my app crashes showing a 404 response ("Unknown symbol").
Using Ruby 3.1.2 and Rails 7.0.2. Please let me know what other information I can provide.