Explorar o código

Handle 4xx errors on request

theenglishway (time) %!s(int64=4) %!d(string=hai) anos
pai
achega
d9051d55be
Modificáronse 1 ficheiros con 3 adicións e 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