فهرست منبع

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