Skip to content

Commit

Permalink
Hide stacktrace in RepoCommonUtils.processError
Browse files Browse the repository at this point in the history
The stack trace is generally useful for diagnostics, but makes admin
life hard if it occurs in known or expected situations. Hence, this
commit makes it optional. It will be displayed only if the logger
for RepoCommonUtils will be set to DEBUG.

This should resolve MID-6695.
  • Loading branch information
mederly committed Sep 22, 2022
1 parent 88f4a5d commit 0db3447
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ static Throwable processConnIdException(Throwable connIdException, String desc,

// We intentionally do not use LOGGER.error here, to avoid dumping the stack unless the DEBUG logging is set.
// This is because ConnID errors often get handled in upper layers. See also MID-5937.
LoggingUtils.logExceptionAsWarning(LOGGER, "Got ConnId exception (might be handled by upper layers later) {} in {}: {}",
LoggingUtils.logExceptionAsWarning(
LOGGER, "Got ConnId exception (might be handled by upper layers later) {} in {}: {}",
connIdException, connIdException.getClass().getName(), desc, connIdException.getMessage());

if (connIdException instanceof RemoteWrappedException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import java.util.List;

import com.evolveum.midpoint.util.logging.LoggingUtils;

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.schema.result.OperationResult;
Expand All @@ -30,20 +32,25 @@ public static void processErrorCriticality(Object object, CriticalityType critic
SecurityViolationException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException {
switch (criticality) {
case FATAL:
LOGGER.debug("Exception {} criticality set as FATAL in {}, stopping evaluation; exception message: {}", e.getClass().getSimpleName(), object, e.getMessage());
LOGGER.error("Fatal error while processing projection on {}: {}", object, e.getMessage(), e);
LOGGER.debug("Exception {} criticality set as FATAL in {}, stopping evaluation; exception message: {}",
e.getClass().getSimpleName(), object, e.getMessage());
LoggingUtils.logExceptionAsWarning( // Intentionally not displaying the full exception (MID-6695)
LOGGER, "An error (potentially recoverable) while processing projection on {}: {}",
e, object, e.getMessage());
throwException(e, result);
throw new AssertionError("not reached");
case PARTIAL:
LOGGER.debug("Exception {} criticality set as PARTIAL in {}, continuing evaluation; exception message: {}", e.getClass().getSimpleName(), object, e.getMessage());
LOGGER.debug("Exception {} criticality set as PARTIAL in {}, continuing evaluation; exception message: {}",
e.getClass().getSimpleName(), object, e.getMessage());
if (result != null) {
result.recordPartialError(e);
}
LOGGER.warn("Partial error while processing projection on {}: {}", object, e.getMessage(), e);
LOGGER.warn("Operation result:\n{}", result != null ? result.debugDump() : "(null)");
break;
case IGNORE:
LOGGER.debug("Exception {} criticality set as IGNORE in {}, continuing evaluation; exception message: {}", e.getClass().getSimpleName(), object, e.getMessage());
LOGGER.debug("Exception {} criticality set as IGNORE in {}, continuing evaluation; exception message: {}",
e.getClass().getSimpleName(), object, e.getMessage());
if (result != null) {
result.recordHandledError(e);
}
Expand Down

0 comments on commit 0db3447

Please sign in to comment.