Skip to content

Commit

Permalink
(fix) elixir-inspector#31 Don't crash on download failures
Browse files Browse the repository at this point in the history
(fix) Require Logger
  • Loading branch information
kyle-neal committed Jun 29, 2023
1 parent fef061f commit ab0bcbb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/ua_inspector/downloader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ defmodule UAInspector.Downloader do
alias UAInspector.Downloader.ShortCodeMapConverter
alias UAInspector.ShortCodeMap

require Logger

@client_hints [
ClientHints.Apps,
ClientHints.Browsers
Expand Down Expand Up @@ -106,8 +108,14 @@ defmodule UAInspector.Downloader do
end

defp download_file(remote, local) do
{:ok, content} = Config.downloader_adapter().read_remote(remote)

File.write!(local, content)
case Config.downloader_adapter().read_remote(remote) do
{:ok, content} ->
File.write!(local, content)
:ok

{:error, reason} ->
Logger.error("Failed to download file: #{reason}")
:ok
end
end
end

0 comments on commit ab0bcbb

Please sign in to comment.