Skip to content

Commit

Permalink
Merge pull request #84 from keboola/kacurez-retry-page-token-error-CO…
Browse files Browse the repository at this point in the history
…M-196

retry on error "This method must be called with a Page Access Token"
  • Loading branch information
kacurez authored Apr 15, 2020
2 parents f03cd67 + 7ca9068 commit adbaf26
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/keboola/facebook/api/request.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,21 @@

(defn skip-error-exception? [e]
(if-let [status (:status e)]
(and
(<= 400 status 500)
(or
(re-find #"Media Posted Before Business Account Conversion" (:body e))))))
(and
(<= 400 status 500)
(or
(re-find #"Media Posted Before Business Account Conversion" (:body e))))))

(defn retry-exception? [e]
(if-let [status (:status e)]
(and
(<= 500 status 600)
(or
(re-find #"Sorry, something went wrong" (:body e))
(re-find #"An unknown error occurred" (:body e))
(re-find #"An unexpected error has occurred. Please retry" (:body e))
(re-find #"Please reduce the amount of data" (:body e))))))
(or (and
(<= 500 status 600)
(or
(re-find #"Sorry, something went wrong" (:body e))
(re-find #"An unknown error occurred" (:body e))
(re-find #"An unexpected error has occurred. Please retry" (:body e))
(re-find #"Please reduce the amount of data" (:body e))))
(re-find #"This method must be called with a Page Access Token" (:body e)))))

(def MIN_TRY_LIMIT_COUNT 3)
(def MIN_TRY_LIMIT 1)
Expand Down Expand Up @@ -209,7 +210,6 @@
(if (some? (-> response :paging :next))
(collect-result (:body (api-fn (-> response :paging :next))) api-fn))))))


(defn- get-request [access-token path & {:keys [query version]}]
(let [query-params (assoc query :access_token access-token)
request-fn (fn [url] (client/GET url :query-params query-params :as :json))
Expand All @@ -219,7 +219,6 @@
(:body (request-fn full-url))
request-fn)))


(defn get-accounts [access-token & {:keys [version]}]
(apply concat (get-request access-token "me/accounts" :version version)))

Expand Down

0 comments on commit adbaf26

Please sign in to comment.