Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#560 exception handling and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsh Patel committed Jan 30, 2021
1 parent b700da2 commit d2e94c0
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -46,8 +46,12 @@ protected ResponseEntity<String> handleSearchResource(final Class<? extends Meta
log.info("Finished searching " + resourceClass + ".");
return ResponseEntity.ok(resource);
} catch (BaseServerResponseException e) {
log.error("BaseServerResponseException - " + e.getMessage());
log.error("BaseServerResponseException - " + e);
return ResponseEntity.status(e.getStatusCode()).body(e.getResponseBody());
} catch (Exception e) {
log.error("Exception - " + e.getMessage());
log.error("Exception - " + e);
return badRequest(e.getMessage());
}
}
Expand Down Expand Up @@ -75,6 +79,7 @@ protected ResponseEntity<String> handleFhirOperation(Parameters parameters, Clas
}

protected String searchResource(final Class<? extends MetadataResource> resourceClass, final String... filters) {
log.info("Building query");
IQuery q = oclFhirUtil.getClient().search().forResource(resourceClass);
if (filters.length % 2 == 0) {
for (int i = 0; i < filters.length; i += 2) {
Expand All @@ -85,7 +90,9 @@ protected String searchResource(final Class<? extends MetadataResource> resource
}
}
}
log.info("Query built and executing the request.");
Bundle bundle = (Bundle) q.execute();
log.info("Request executed successfully.");
return oclFhirUtil.getResourceAsString(bundle);
}

Expand Down

0 comments on commit d2e94c0

Please sign in to comment.