Explorar el Código

Handle 4xx errors on request

theenglishway (time) hace 4 años
padre
commit
d9051d55be
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      lib/vaccins/scraper.ex

+ 3 - 0
lib/vaccins/scraper.ex

@@ -11,6 +11,9 @@ defmodule Vaccins.Scraper do
       {:ok, %{headers: headers, status: 301}} ->
         headers |> Map.new() |> Map.get("location") |> get_body
 
+      {:ok, %{status: status}} when status >= 400 ->
+        {:error, status}
+
       e = {:error, _} ->
         e
     end