From f360199e0c63155ec06a071d96316d5740542960 Mon Sep 17 00:00:00 2001 From: gered Date: Fri, 4 Jul 2014 09:40:51 -0400 Subject: [PATCH] return nil if the resource could not be found (http 404) --- src/clj_hl7_fhir/core.clj | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/clj_hl7_fhir/core.clj b/src/clj_hl7_fhir/core.clj index f34d59e..30a4d58 100644 --- a/src/clj_hl7_fhir/core.clj +++ b/src/clj_hl7_fhir/core.clj @@ -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."