• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 11611100303

31 Oct 2024 11:29AM UTC coverage: 66.915% (+0.2%) from 66.715%
11611100303

push

github

web-flow
#608: enhance error messages (#653)

2415 of 3952 branches covered (61.11%)

Branch coverage included in aggregate %.

6302 of 9075 relevant lines covered (69.44%)

3.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.1
cli/src/main/java/com/devonfw/tools/ide/process/ProcessResultImpl.java
1
package com.devonfw.tools.ide.process;
2

3
import java.util.Collections;
4
import java.util.List;
5
import java.util.Objects;
6

7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.log.IdeLogLevel;
9

10
/**
11
 * Implementation of {@link ProcessResult}.
12
 */
13
public class ProcessResultImpl implements ProcessResult {
14

15
  private final int exitCode;
16

17
  private final List<String> out;
18

19
  private final List<String> err;
20

21
  /**
22
   * The constructor.
23
   *
24
   * @param exitCode the {@link #getExitCode() exit code}.
25
   * @param out the {@link #getOut() out}.
26
   * @param err the {@link #getErr() err}.
27
   */
28
  public ProcessResultImpl(int exitCode, List<String> out, List<String> err) {
29

30
    super();
2✔
31
    this.exitCode = exitCode;
3✔
32
    this.out = Objects.requireNonNullElse(out, Collections.emptyList());
6✔
33
    this.err = Objects.requireNonNullElse(err, Collections.emptyList());
6✔
34
  }
1✔
35

36
  @Override
37
  public int getExitCode() {
38

39
    return this.exitCode;
3✔
40
  }
41

42
  @Override
43
  public List<String> getOut() {
44

45
    return this.out;
3✔
46
  }
47

48
  @Override
49
  public List<String> getErr() {
50

51
    return this.err;
3✔
52
  }
53

54
  @Override
55
  public void log(IdeLogLevel level, IdeContext context) {
56
    log(level, context, level);
5✔
57
  }
1✔
58

59
  public void log(IdeLogLevel outLevel, IdeContext context, IdeLogLevel errorLevel) {
60

61
    if (!this.out.isEmpty()) {
4✔
62
      doLog(outLevel, this.out, context);
6✔
63
    }
64
    if (!this.err.isEmpty()) {
4✔
65
      doLog(errorLevel, this.err, context);
6✔
66
    }
67
  }
1✔
68

69
  private void doLog(IdeLogLevel level, List<String> lines, IdeContext context) {
70
    for (String line : lines) {
10✔
71
      // remove !MESSAGE from log message
72
      if (line.startsWith("!MESSAGE ")) {
4!
73
        line = line.substring(9);
×
74
      }
75
      context.level(level).log(line);
5✔
76
    }
1✔
77
  }
1✔
78

79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc