Wrap exceptions thrown by class builders and add details about class file being generated.

This commit is contained in:
Ilya Gorbunov
2016-01-29 19:01:06 +03:00
parent 5f38c1d571
commit 3ae4c033b6
@@ -286,13 +286,23 @@ public class ClassFileFactory implements OutputFileCollection {
@NotNull
@Override
public byte[] asByteArray() {
return generators.get(relativeClassFilePath).asBytes(builderFactory);
try {
return generators.get(relativeClassFilePath).asBytes(builderFactory);
}
catch (RuntimeException e) {
throw new RuntimeException("Error generating class file " + this.toString() + ": " + e.getMessage(), e);
}
}
@NotNull
@Override
public String asText() {
return generators.get(relativeClassFilePath).asText(builderFactory);
try {
return generators.get(relativeClassFilePath).asText(builderFactory);
}
catch (RuntimeException e) {
throw new RuntimeException("Error generating class file " + this.toString() + ": " + e.getMessage(), e);
}
}
@NotNull