Handling the error "HTTP.ExceptionRequest.StatusError"

In the process of getting price data from Yahoo Finance, sometimes a ticker is missing. In that case, I get the error HTTP.ExceptionRequest.StatusError

How do I handle this error such that, when it occurs, I can continue my script (in my case, go to the next ticker in my list of tickers)?

To get an idea of what I am trying to do …

if iserror(HTTP.get(address)) == false
   do stuff
else
   next
end

I think something like the following would work in my case:

try
    res = HTTP.get(address)
catch e
    println("That ticker does not exist on Yahoo!")
end

Yes, but also have you seen

Rather than reinventing the wheel with barebones HTTP requests?

You can tell HTTP.jl not to throw StatusErrors by passing status_exception=false as a keyword argument:

r = HTTP.get(url; status_exception=false)
HTTP.iserror(r)