Add Exception bad XML format

This commit is contained in:
Andros Fenollosa 2022-02-15 15:02:40 +01:00
parent 6a63cd04d4
commit 91b2c85fcc
2 changed files with 18 additions and 11 deletions

View File

@ -1,4 +1,4 @@
(defproject rsspaper "1.2.2" (defproject rsspaper "1.2.3"
:description "RSSpaper" :description "RSSpaper"
:url "https://github.com/tanrax/RSSpaper" :url "https://github.com/tanrax/RSSpaper"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"

View File

@ -80,16 +80,23 @@
(-> (->
(reduce (reduce
(fn [feeds feed-url] (fn [feeds feed-url]
; Read feed (try
(let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})] ; Read feed
; User feedback (let [feed (parse-url feed-url {:insecure? true})]
(prn (str "Reading RSS > " feed-url)) ; User feedback
; Check is not null (prn (str "Reading RSS > " feed-url))
(if-not (nil? feed) ; Check is not null
; Add feed and add key feed original (if-not (nil? feed)
(conj feeds (assoc feed :feed-url feed-url)) ; Add feed and add key feed original
; Alert fail (conj feeds (assoc feed :feed-url feed-url))
(prn (str "Error with '" feed-url) "'")))) ; Alert fail
(prn (str "Error with '" feed-url) "'")))
(catch clojure.lang.ExceptionInfo e
(let [response (ex-data e)
{:keys [status headers]} response]
(prn (str feed-url " has been ignored because of bad formatting."))
;; do anything you want
))))
[] (:feeds config)) [] (:feeds config))
zip-feeds-in-articles zip-feeds-in-articles
datetimes-to-unixtime datetimes-to-unixtime