Skip to content

Commit

Permalink
#877: improved process error message (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-vcapgemini authored Dec 12, 2024
1 parent 75f5043 commit 68713f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,9 @@ private String addExecutable(String exec, List<String> args) {
private void performLogging(ProcessResult result, int exitCode, String interpreter) {

if (!result.isSuccessful() && (this.errorHandling != ProcessErrorHandling.NONE)) {
IdeLogLevel ideLogLevel;
IdeLogLevel ideLogLevel = this.errorHandling.getLogLevel();
String message = createCommandMessage(interpreter, "\nfailed with exit code " + exitCode + "!");

if (this.errorHandling == ProcessErrorHandling.LOG_ERROR) {
ideLogLevel = IdeLogLevel.ERROR;
} else if (this.errorHandling == ProcessErrorHandling.LOG_WARNING) {
ideLogLevel = IdeLogLevel.WARNING;
} else {
ideLogLevel = IdeLogLevel.ERROR;
this.context.error("Internal error: Undefined error handling {}", this.errorHandling);
}

context.level(ideLogLevel).log(message);
result.log(ideLogLevel, context);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.devonfw.tools.ide.process;

import com.devonfw.tools.ide.log.IdeLogLevel;

/**
* {@link Enum} with the available handling if a {@link Process#exitValue() status code} was not {@link ProcessResult#SUCCESS successful}.
*/
Expand All @@ -26,6 +28,15 @@ public enum ProcessErrorHandling {
* Throw an exception if the status code was not successful. In this case the {@link ProcessContext#run() run} method will never return an exit code other
* than {@link ProcessResult#SUCCESS} as otherwise an exception is thrown preventing the method to return.
*/
THROW_ERR
THROW_ERR;

/**
* @return the matching {@link IdeLogLevel}.
*/
public IdeLogLevel getLogLevel() {
if (this.equals(LOG_WARNING)) {
return IdeLogLevel.WARNING;
}
return IdeLogLevel.ERROR;
}
}

0 comments on commit 68713f1

Please sign in to comment.