aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/sonarsource/scanner/cli/Main.java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2024-05-07 17:39:21 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2024-05-13 09:37:44 +0200
commit9e72835bb09a703c7bb91ba387fef09f881d5418 (patch)
tree5c2bd132588cdfc824bd550a052c297e7569ed09 /src/main/java/org/sonarsource/scanner/cli/Main.java
parentf2df80dbd277ffa97d2d43f8e44368944d3e1e4b (diff)
downloadsonar-scanner-cli-9e72835bb09a703c7bb91ba387fef09f881d5418.tar.gz
sonar-scanner-cli-9e72835bb09a703c7bb91ba387fef09f881d5418.zip
Log improvements
Diffstat (limited to 'src/main/java/org/sonarsource/scanner/cli/Main.java')
-rw-r--r--src/main/java/org/sonarsource/scanner/cli/Main.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/org/sonarsource/scanner/cli/Main.java b/src/main/java/org/sonarsource/scanner/cli/Main.java
index 7ec139d..df60585 100644
--- a/src/main/java/org/sonarsource/scanner/cli/Main.java
+++ b/src/main/java/org/sonarsource/scanner/cli/Main.java
@@ -43,7 +43,6 @@ import org.sonarsource.scanner.lib.ScannerProperties;
public class Main {
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
- private static final String SEPARATOR = "------------------------------------------------------------------------";
private final Exit exit;
private final Cli cli;
private final Conf conf;
@@ -75,13 +74,18 @@ public class Main {
init(p);
try (var engine = scannerEngineBootstrapper.bootstrap()) {
logServerType(engine);
- engine.analyze((Map) p);
- displayExecutionResult(stats, "SUCCESS");
- status = Exit.SUCCESS;
+ var success = engine.analyze((Map) p);
+ if (success) {
+ displayExecutionResult(stats, "SUCCESS");
+ status = Exit.SUCCESS;
+ } else {
+ displayExecutionResult(stats, "FAILURE");
+ status = Exit.SCANNER_ENGINE_ERROR;
+ }
}
} catch (Throwable e) {
displayExecutionResult(stats, "FAILURE");
- showError("Error during SonarScanner CLI execution", e, cli.isDebugEnabled());
+ showError(e, cli.isDebugEnabled());
status = isUserError(e) ? Exit.USER_ERROR : Exit.INTERNAL_ERROR;
} finally {
exit.exit(status);
@@ -123,14 +127,12 @@ public class Main {
}
private static void displayExecutionResult(Stats stats, String resultMsg) {
- LOG.info(SEPARATOR);
LOG.info("EXECUTION {}", resultMsg);
- LOG.info(SEPARATOR);
stats.stop();
- LOG.info(SEPARATOR);
}
- private void showError(String message, Throwable e, boolean debug) {
+ private void showError(Throwable e, boolean debug) {
+ var message = "Error during SonarScanner CLI execution";
if (debug || !isUserError(e)) {
LOG.error(message, e);
} else {