com.hyf.hotrefresh.core.exception.CompileException Maven / Gradle / Ivy
package com.hyf.hotrefresh.core.exception;
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
import java.util.*;
/**
* @author baB_hyf
* @date 2021/12/12
*/
public class CompileException extends RefreshException {
private List> diagnostics;
public CompileException(String message) {
super(message);
}
public CompileException(String message, Throwable cause) {
super(message, cause);
}
public CompileException(String message, List> diagnostics) {
super(message);
this.diagnostics = diagnostics;
}
@Override
public String getMessage() {
return super.getMessage() + "\n" + getErrors();
}
private String getErrors() {
StringBuilder errors = new StringBuilder();
for (Map message : getErrorList()) {
for (Map.Entry entry : message.entrySet()) {
Object value = entry.getValue();
if (value != null && !value.toString().isEmpty()) {
errors.append(entry.getKey());
errors.append(": ");
errors.append(value);
}
errors.append(" , ");
}
errors.append("\n");
}
return errors.toString();
}
private List