forked from trung/InMemoryJavaCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompilationException.java
More file actions
25 lines (21 loc) · 849 Bytes
/
CompilationException.java
File metadata and controls
25 lines (21 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package org.mdkt.compiler;
import java.util.List;
import java.util.Locale;
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
public class CompilationException extends RuntimeException {
private static final long serialVersionUID = 5272588827551900536L;
public CompilationException(List<Diagnostic<? extends JavaFileObject>> diags) {
super(buildMessage(diags));
}
private static String buildMessage(List<Diagnostic<? extends JavaFileObject>> diags) {
StringBuffer msg = new StringBuffer();
msg.append("Unable to compile the source.");
for (Diagnostic<?> diag : diags) {
msg.append("\n").append("[kind=").append(diag.getKind());
msg.append(", ").append("line=").append(diag.getLineNumber());
msg.append(", ").append("message=").append(diag.getMessage(Locale.US)).append("]");
}
return msg.toString();
}
}