Skip to content

Commit

Permalink
Remove exceptions printing stack traces (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
JPercival authored Nov 27, 2023
1 parent 0d5a670 commit 2985f47
Show file tree
Hide file tree
Showing 17 changed files with 14 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public static CqlTranslatorOptions fromFile(String fileName) {
fr = new FileReader(fileName);
return fromReader(fr);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(String.format("Errors occurred reading options: %s", e.getMessage()));
}
}
Expand All @@ -22,7 +21,6 @@ public static CqlTranslatorOptions fromReader(Reader reader) {
try {
return om.readValue(reader, CqlTranslatorOptions.class);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(String.format("Errors occurred reading options: %s", e.getMessage()));
}
}
Expand All @@ -33,7 +31,6 @@ public static void toFile(String fileName, CqlTranslatorOptions options) {
fw = new FileWriter(fileName);
toWriter(fw, options);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(String.format("Errors occurred writing options: %s", e.getMessage()));
}
}
Expand All @@ -43,7 +40,6 @@ public static void toWriter(Writer writer, CqlTranslatorOptions options) {
try {
om.writeValue(writer, options);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(String.format("Errors occurred writing options: %s", e.getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public boolean accept(File path, String name) {
return ModelInfoReaderFactory.getReader("application/xml").read(is);
}
} catch (IOException e) {
e.printStackTrace();
throw new IllegalArgumentException(String.format("Could not load definition for model info %s.", modelIdentifier.getId()), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private CompiledLibrary generateCompiledLibraryFromElm(VersionedIdentifier libra
try {
library = ElmLibraryReaderFactory.getReader(type.mimeType()).read(new InputStreamReader(librarySource));
} catch (IOException e) {
e.printStackTrace();
// intentionally ignored
}

if (library != null && checkBinaryCompatibility(library)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public static JAXBContext getJaxbContext() {
try {
jaxbContext = JAXBContext.newInstance(Library.class, CqlToElmBase.class);
} catch (JAXBException e) {
e.printStackTrace();
throw new RuntimeException("Error creating JAXBContext - " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.cqframework.cql.elm.serializing.jaxb;

import org.hl7.cql_annotations.r1.CqlToElmBase;
import org.hl7.elm.r1.Library;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;

Expand All @@ -15,7 +12,6 @@ public static JAXBContext getJaxbContext() {
try {
jaxbContext = JAXBContext.newInstance(org.hl7.elm.r1.ObjectFactory.class, org.hl7.cql_annotations.r1.ObjectFactory.class);
} catch (JAXBException e) {
e.printStackTrace();
throw new RuntimeException("Error creating JAXBContext - " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,8 @@ protected void initialize() {
Method m = this.fhirContext.getClass().getDeclaredMethod("scanResourceTypes", Collection.class);
m.setAccessible(true);
m.invoke(this.fhirContext, toLoad);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (Exception e) {
// intentionally ignored
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,8 @@ protected void initialize() {
Method m = this.fhirContext.getClass().getDeclaredMethod("scanResourceTypes", Collection.class);
m.setAccessible(true);
m.invoke(this.fhirContext, toLoad);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (Exception e) {
// intentionally ignored
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,8 @@ protected void initialize() {
Method m = this.fhirContext.getClass().getDeclaredMethod("scanResourceTypes", Collection.class);
m.setAccessible(true);
m.invoke(this.fhirContext, toLoad);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (Exception e) {
// intentionally ignored
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,10 @@ protected void initialize() {
Method m = this.fhirContext.getClass().getDeclaredMethod("scanResourceTypes", Collection.class);
m.setAccessible(true);
m.invoke(this.fhirContext, toLoad);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (Exception e) {
// intentionally ignored
}

}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
try {
return ModelInfoReaderFactory.getReader("application/xml").read(SystemModelInfoProvider.class.getResourceAsStream("/org/hl7/elm/r1/system-modelinfo.xml"));
} catch (IOException e) {
e.printStackTrace();
// Do not throw, allow other providers to resolve
// throw new IllegalArgumentException(String.format("Unknown version %s of the System model.", localVersion));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
return ModelInfoReaderFactory.getReader("application/xml").read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-5.6.xml"));
}
} catch (IOException e) {
e.printStackTrace();
// Do not throw, allow other providers to resolve
// throw new IllegalArgumentException(String.format("Unknown version %s of the QDM model.", localVersion));
// Do not throw, allow other providers to resolve
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
// throw new IllegalArgumentException(String.format("Unknown version %s of the FHIR model.", localVersion));
}
} catch (IOException e) {
e.printStackTrace();
// Do not throw, allow other providers to resolve
// throw new IllegalArgumentException(String.format("Unknown version %s of the Fhir model.", localVersion));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
return ModelInfoReaderFactory.getReader("application/xml").read(QICoreModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/qicore-modelinfo-5.0.0.xml"));
}
} catch (IOException e) {
e.printStackTrace();
// Do not throw, allow other providers to resolve
// throw new IllegalArgumentException(String.format("Unknown version %s of the QI model.", localVersion));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
return ModelInfoReaderFactory.getReader("application/xml").read(QuickFhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/quickfhir-modelinfo-3.0.1.xml"));
}
} catch (IOException e) {
e.printStackTrace();
// Do not throw, allow other providers to resolve
// throw new IllegalArgumentException(String.format("Unknown version %s of the QUICKFHIR model.", localVersion));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private boolean isQuickModelIdentifier(ModelIdentifier modelIdentifier) {
public ModelInfo load(ModelIdentifier modelIdentifier) {
if (isQuickModelIdentifier(modelIdentifier)) {
String localVersion = modelIdentifier.getVersion() == null ? "" : modelIdentifier.getVersion();

try {
switch (localVersion) {
case "3.3.0":
Expand All @@ -38,11 +38,9 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
return ModelInfoReaderFactory.getReader("application/xml").read(QuickModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/quick-modelinfo.xml"));
}
} catch (IOException e) {
e.printStackTrace();
// Do not throw, allow other providers to resolve
// throw new IllegalArgumentException(String.format("Unknown version %s of the Fhir model.", localVersion));
}

}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
return ModelInfoReaderFactory.getReader("application/xml").read(QuickModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/uscore-modelinfo-3.1.1.xml"));
}
} catch (IOException e) {
e.printStackTrace();
// Do not throw, allow other providers to resolve
// throw new IllegalArgumentException(String.format("Unknown version %s of the Fhir model.", localVersion));
}

}

return null;
Expand Down

0 comments on commit 2985f47

Please sign in to comment.