refactor: reduce cogn complexity in ExitCodeUtility (low hanging fruit; we'll see if it's enough)
@@ -59,6 +59,17 @@ public class ExitCodeUtility {
logger.debug(e.getMessage(), e);
exceptionExitCodeType = ExitCodeType.FAILURE_CONFIGURATION;
} else {
+ logUnrecognizedException(e);
+ exceptionExitCodeType = ExitCodeType.FAILURE_UNKNOWN_ERROR;
+ }
+ if (e.getMessage() != null) {
+ logger.error(e.getMessage());
+ }
+
+ return exceptionExitCodeType;
+ }
+
+ private void logUnrecognizedException(Exception e) {
logger.error("An unknown/unexpected error occurred");
if (e.getMessage() != null) {
logger.error(e.getMessage());
@@ -70,12 +81,5 @@ public class ExitCodeUtility {
if (e.getStackTrace().length >= 1) {
logger.error("Thrown at " + e.getStackTrace()[0].toString());
}
- exceptionExitCodeType = ExitCodeType.FAILURE_UNKNOWN_ERROR;
- }
- if (e.getMessage() != null) {
- logger.error(e.getMessage());
- }
-
- return exceptionExitCodeType;
}
}
