diff --git a/src/clj_htmltopdf/core.clj b/src/clj_htmltopdf/core.clj index e11a5b7..3c5cf89 100644 --- a/src/clj_htmltopdf/core.clj +++ b/src/clj_htmltopdf/core.clj @@ -16,48 +16,31 @@ (defn- read-html [in] - (try - (cond - (string? in) in - (sequential? in) (h/html5 {} in) - :else (with-open [r (io/reader in)] - (slurp r))) - (catch Exception ex - (throw (Exception. "Error reading HTML from input." ex))))) + (cond + (string? in) in + (sequential? in) (h/html5 {} in) + :else (with-open [r (io/reader in)] + (slurp r)))) (defn- ->output-stream [out] - (try - (if (instance? OutputStream out) - out - (io/output-stream out)) - (catch Exception ex - (throw (Exception. "Error preparing an OutputStream from output given." ex))))) - -(defn- parse-jsoup-html - [^String html] - (try - (Jsoup/parse html) - (catch Exception ex - (throw (Exception. "Error parsing input HTML to Jsoup Document." ex))))) + (if (instance? OutputStream out) + out + (io/output-stream out))) (defn- set-jsoup-html-doc [^PdfRendererBuilder builder jsoup-doc base-uri] - (try - (let [doc (DOMBuilder/jsoup2DOM jsoup-doc)] - (.withW3cDocument builder doc base-uri)) - (catch Exception ex - (throw (Exception. "Error setting org.w3c.dom.Document HTML." ex))))) + (let [doc (DOMBuilder/jsoup2DOM jsoup-doc)] + (.withW3cDocument builder doc base-uri))) (defn ->pdf [in out & [options]] (let [options (merge o/default-options options) builder (PdfRendererBuilder.) html (read-html in) - html-doc (parse-jsoup-html html) + html-doc (Jsoup/parse html) html-doc (o/inject-options-into-html html-doc options) output (->output-stream out)] - html-doc (if (:logging? options) (let [logger (:logger options)] (if logger (XRLog/setLoggerImpl logger))