*
*/
public class PlayExceptionUtils {
public static Exception mapJapidJavaCodeError(Exception ex) {
if (ex instanceof CompilationException) {
CompilationException e = (CompilationException) ex;
if (!e.isSourceAvailable())
return e;
// now map java error to japidview source code
String srcFilePath = e.getSourceFile();
if (!srcFilePath.startsWith("/app/japidviews/")) {
return e;
}
else if (!srcFilePath.endsWith("java")) {
return e;
}
String viewSourceFilePath = DirUtil.mapJavaToSrc(srcFilePath);
// File file = new File(viewSourceFilePath);
VirtualFile vf = VirtualFile.fromRelativePath(viewSourceFilePath);
int oriLineNumber = mapJavaErrorLineToSrcLine(e.getSourceVirtualFile().contentAsString(), e.getLineNumber());
e = new CompilationException(vf, "\"" + e.getMessage() + "\"", oriLineNumber, 0, 0);
return e;
}
return ex;
}