if (jspFrame == null ||
this.ctxt.getCompiler().getPageNodes() == null) {
// If we couldn't find a frame in the stack trace corresponding
// to the generated servlet class or we don't have a copy of the
// parsed JSP to hand, we can't really add anything
return new JasperException(ex);
}
else {
int javaLineNumber = jspFrame.getLineNumber();
JavacErrorDetail detail = ErrorDispatcher.createJavacError(
jspFrame.getMethodName(),
this.ctxt.getCompiler().getPageNodes(),
null,
javaLineNumber,
ctxt);
// If the line number is less than one we couldn't find out
// where in the JSP things went wrong
int jspLineNumber = detail.getJspBeginLineNumber();
if (jspLineNumber < 1) {
throw new JasperException(ex);
}
if (options.getDisplaySourceFragment()) {
return new JasperException(Localizer.getMessage
("jsp.exception", detail.getJspFileName(),
"" + jspLineNumber) +
"\n\n" + detail.getJspExtract() +
"\n\nStacktrace:", ex);
} else {
return new JasperException(Localizer.getMessage
("jsp.exception", detail.getJspFileName(),
"" + jspLineNumber), ex);
}
}
} catch (Exception je) {
// If anything goes wrong, just revert to the original behaviour
if (ex instanceof JasperException) {
return (JasperException) ex;
} else {
return new JasperException(ex);
}
}
}