-
Notifications
You must be signed in to change notification settings - Fork 12
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
Make exceptions a bit more informative #1255
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1255 +/- ##
=========================================
Coverage 91.09% 91.10%
Complexity 4641 4641
=========================================
Files 596 596
Lines 14678 14683 +5
Branches 831 831
=========================================
+ Hits 13371 13377 +6
Misses 1046 1046
+ Partials 261 260 -1 |
@@ -74,6 +74,7 @@ | |||
<inspection_tool class="BigDecimalEquals" enabled="true" level="WARNING" enabled_by_default="true" /> | |||
<inspection_tool class="BreakStatement" enabled="true" level="WARNING" enabled_by_default="true" /> | |||
<inspection_tool class="BreakStatementWithLabel" enabled="true" level="WARNING" enabled_by_default="true" /> | |||
<inspection_tool class="BusyWait" enabled="true" level="WARNING" enabled_by_default="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please synchronize this file with the config
module. It might be that your local settings are infiltrating the repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually got these changes from the config/pull
. Right now they are identical.
@@ -431,7 +432,8 @@ final void importEvent(EventEnvelope event) { | |||
I id = ids.stream() | |||
.findFirst() | |||
.orElseThrow(() -> newIllegalStateException( | |||
"Unable to route import event `%s`.", messageType) | |||
"Unable to route import event `%s`. Event: %s", | |||
messageType, shortDebugString(message)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging an event body is a security concern. Please only log the meta-data, such as event ID and timestamp.
throw newIllegalStateException("Aggregate %s (ID: %s) cannot be loaded.%n", | ||
aggregateClass().value().getName(), | ||
result.idAsString()); | ||
throw newIllegalStateException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the formatting. The policy is not to split the method and the first param if possible, i.e. if the char count is not too big.
aggregateClass().value().getName(), | ||
result.idAsString()); | ||
throw newIllegalStateException( | ||
"Aggregate %s (ID: %s) cannot be loaded.%n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Aggregate %s (ID: %s) cannot be loaded.%n", | |
"Aggregate `%s` (ID: %s) cannot be loaded.%n", |
@@ -112,7 +112,11 @@ private static EventMessage systemEventFor(Status status, CommandId commandId) { | |||
.build(); | |||
case REJECTION: | |||
default: | |||
throw newIllegalArgumentException("Invalid status %s.", status.getStatusCase()); | |||
throw newIllegalArgumentException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this error popped up in your log? If so, this is a bug or a compatibility issue worth paying attention to. Let's discuss if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, not really. I looked over the other messages that could have a bit more useful info.
@@ -426,7 +428,7 @@ protected E findOrCreate(I id) { | |||
|
|||
private E findOrThrow(I id) { | |||
return find(id).orElseThrow(() -> newIllegalArgumentException( | |||
"An entity with ID `%s` is not found in the repository.", id | |||
"An entity `%s` with ID `%s` is not found in the repository.", entityClass(), id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure the word class
is not added to the message before the class name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuri-sergiichuk, LGTM with a single comment to address.
@@ -431,7 +431,8 @@ final void importEvent(EventEnvelope event) { | |||
I id = ids.stream() | |||
.findFirst() | |||
.orElseThrow(() -> newIllegalStateException( | |||
"Unable to route import event `%s`.", messageType) | |||
"Unable to route import event `%s`. Event: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's still a placeholder left.
In the PR I have added some more informative context to exceptions thrown by the framework.
The initial trigger for the change was an exception thrown by the migration process with as little info as: