Skip to content

Commit

Permalink
log state name that threw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Edvard Fonsell committed Feb 1, 2021
1 parent c0420cf commit c28b3e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,16 @@ private void runImpl() {

private void logRetryableException(WorkflowState state, Throwable t) {
ExceptionSeverity exceptionSeverity = state.getExceptionSeverity(t);
BiConsumer<String, Object> logMethod = getLogMethod(exceptionSeverity.logLevel);
BiConsumer<String, Object[]> logMethod = getLogMethod(exceptionSeverity.logLevel);
if (exceptionSeverity.logStackTrace) {
logMethod.accept("Handler threw a retryable exception, trying again later.", t);
logMethod.accept("Handling state '{}' threw a retryable exception, trying again later.", new Object[] { state.name(), t });
} else {
logMethod.accept("Handler threw a retryable exception, trying again later. Message: {}", t.getMessage());
logMethod.accept("Handling state '{}' threw a retryable exception, trying again later. Message: {}",
new Object[] { state.name(), t.getMessage() });
}
}

private BiConsumer<String, Object> getLogMethod(Level logLevel) {
private BiConsumer<String, Object[]> getLogMethod(Level logLevel) {
switch (logLevel) {
case TRACE:
return logger::trace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.slf4j.event.Level;

public class ExceptionSeverity {
public static final ExceptionSeverity DEFAULT = new ExceptionSeverity(ERROR, true);
public static final ExceptionSeverity DEFAULT = new ExceptionSeverity.Builder().build();
public final Level logLevel;
public final boolean logStackTrace;

Expand Down

0 comments on commit c28b3e2

Please sign in to comment.