소스 검색

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