tzdata icon indicating copy to clipboard operation
tzdata copied to clipboard

Trying not to crash

Open h4cc opened this issue 8 years ago • 2 comments

It would be cool, when DataLoader.download_new would not crash on timeouts/etc. A Logger.warn would be nicer, instead of getting a alarm from Sentry :(

https://github.com/lau/tzdata/blob/master/lib/tzdata/data_loader.ex#L10

Anybody willing to work on this?

h4cc avatar Nov 22 '17 09:11 h4cc

That's probably because the url changed to https://data.iana.org/time-zones/releases/tzdata2017c.tar.gz- let me pr this quickly.

madsheep avatar Nov 22 '17 09:11 madsheep

Thanks, but that is not exactly what i meant.

I had something like this in mind:

# instead of this what will crash unnecessarily
{:ok, 200, headers, client_ref} = :hackney.get(url, [], "", [follow_redirect: true])

# refactor the code like this:
case :hackney.get(url, [], "", [follow_redirect: true]) do
  {:ok, 200, headers, client_ref} ->
    # rest of code
  error ->
    Logger.warn("Fetching #{inspect url} failed because of error #{inspect error}")
    error
end

h4cc avatar Nov 25 '17 12:11 h4cc