return nil if the resource could not be found (http 404)

This commit is contained in:
Gered 2014-07-04 09:40:51 -04:00
parent 23a4bce89c
commit f360199e0c

View file

@ -1,5 +1,6 @@
(ns clj-hl7-fhir.core
(:import (java.util Date))
(:import (java.util Date)
(clojure.lang ExceptionInfo))
(:require [clojure.string :as str]
[clj-http.client :as http]
[cheshire.core :as json])
@ -67,9 +68,13 @@
url-components (if version
["/" resource-name id "_history" version]
["/" resource-name id])]
(fhir-get-request
base-url
(apply join-paths url-components))))
(try
(fhir-get-request
base-url
(apply join-paths url-components))
(catch ExceptionInfo ex
(if (not= 404 (get-in (ex-data ex) [:object :status]))
(throw ex))))))
(defn get-resource-bundle
"gets a single resource from a FHIR server that is contained in a bundle."