瀏覽代碼

Handle 4xx errors on request

theenglishway (time) 4 年之前
父節點
當前提交
d9051d55be
共有 1 個文件被更改,包括 3 次插入0 次删除
  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