implements PR-O1.1
This commit is contained in:
+26
-3
@@ -10,16 +10,39 @@ public class BuildingIssue {
|
||||
private final boolean error;
|
||||
private final String message;
|
||||
private final Throwable exception;
|
||||
private final String phase;
|
||||
private final String code;
|
||||
private final Integer functionIndex;
|
||||
private final Integer pc;
|
||||
|
||||
public void print(LogAggregator logs) {
|
||||
final var composed = composeMessage();
|
||||
if (error) {
|
||||
if (exception != null) {
|
||||
logs.error(message, exception);
|
||||
logs.error(composed, exception);
|
||||
} else {
|
||||
logs.error(message);
|
||||
logs.error(composed);
|
||||
}
|
||||
} else {
|
||||
logs.warn(message);
|
||||
logs.warn(composed);
|
||||
}
|
||||
}
|
||||
|
||||
private String composeMessage() {
|
||||
final var sb = new StringBuilder();
|
||||
if (phase != null && !phase.isBlank()) {
|
||||
sb.append('[').append(phase).append(']').append(' ');
|
||||
}
|
||||
if (code != null && !code.isBlank()) {
|
||||
sb.append('(').append(code).append(')').append(' ');
|
||||
}
|
||||
sb.append(message == null ? "" : message);
|
||||
if (functionIndex != null && functionIndex >= 0) {
|
||||
sb.append(" [fn=").append(functionIndex).append(']');
|
||||
}
|
||||
if (pc != null && pc >= 0) {
|
||||
sb.append(" [pc=").append(pc).append(']');
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user