From 19c22e0a0d6523225ec423baf7c573ec886de9e4 Mon Sep 17 00:00:00 2001 From: Sean McIlvenna Date: Wed, 6 Feb 2019 22:38:59 -0800 Subject: [PATCH] Re-throwing handled exception as configuration exceptions --- .../java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java | 13 +++---------- .../java/ca/uhn/fhir/jpa/demo/HapiProperties.java | 7 +++---- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java b/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java index 6d5cc41..f1cd8f6 100644 --- a/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/demo/FhirServerConfig.java @@ -7,6 +7,7 @@ import java.util.Properties; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; +import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; @@ -82,16 +83,8 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 { try { retVal.setDataSource(dataSource()); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); + } catch (Exception e) { + throw new ConfigurationException("Could not set the data source due to a configuration issue", e); } retVal.setJpaProperties(jpaProperties()); diff --git a/src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java b/src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java index 3c889be..a04a429 100644 --- a/src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/demo/HapiProperties.java @@ -1,5 +1,6 @@ package ca.uhn.fhir.jpa.demo; +import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.server.ETagSupportEnum; @@ -45,10 +46,8 @@ public class HapiProperties { HapiProperties.properties = new Properties(); HapiProperties.properties.load(in); in.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + } catch (Exception e) { + throw new ConfigurationException("Could not load HAPI properties", e); } }