Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop swallowing exceptions in the $everything operation #2950

Merged
merged 1 commit into from
Nov 8, 2021
Merged

Conversation

lmsurpre
Copy link
Member

@lmsurpre lmsurpre commented Nov 6, 2021

Signed-off-by: Lee Surprenant lmsurpre@us.ibm.com

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
@lmsurpre lmsurpre requested a review from prb112 November 6, 2021 02:30
@@ -250,7 +258,8 @@ protected Parameters doInvoke(FHIROperationContext operationContext, Class<? ext
try {
outputParameters = FHIROperationUtil.getOutputParameters(bundleBuilder.build());
} catch (Exception e) {
FHIROperationException exceptionWithIssue = buildExceptionWithIssue("An unexpected error occurred while creating the operation output parameters for the resulting Bundle.", IssueType.EXCEPTION);
FHIROperationException exceptionWithIssue = buildExceptionWithIssue("An unexpected error occurred while "
+ "creating the operation output parameters for the resulting Bundle.", IssueType.EXCEPTION, e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the PR review we asked that Luis not send back the exceptions. This is a bit of a design change.
I think this deserves a bit of javadoc explaining the choice so we don't go revisit this in the future and flip the other way.

Copy link
Member Author

@lmsurpre lmsurpre Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to either log the exceptions or add them to the wrapped exception, otherwise they are swallowed and its nearly impossible to know what went wrong.

Are you thinking javadoc at each location where we catch + wrap? Or just mention it once at the class level?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just thinking at the class level.

Copy link
Member Author

@lmsurpre lmsurpre Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, how about I add something to our style guide at https://github.com/IBM/FHIR/wiki/Style-Guide about it instead?
maybe an ammendment to 24. Only catch an exception if you can do something about it...or need to
I could add a blurb about "rethrow, wrap, log and throw new, or handle; don't swallow unless you handle it"?

Copy link
Contributor

@prb112 prb112 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, (adding the Javadoc is just a nice to have)

@lmsurpre lmsurpre merged commit 9bbc4a7 into main Nov 8, 2021
@lmsurpre lmsurpre deleted the lee-main branch November 8, 2021 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants