Skip to content

Commit 1a316cc

Browse files
author
Igor Polevoy
committed
#369 RequestDispatcher puts out an exception without a stack trace.
1 parent cb2f54f commit 1a316cc

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

activeweb/src/main/java/org/javalite/activeweb/RequestDispatcher.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain
234234

235235
private Map getMapWithExceptionDataAndSession(Throwable e) {
236236
return map("message", e.getMessage() == null ? e.toString() : e.getMessage(),
237-
"stack_trace", getStackTraceString(e),
237+
"stack_trace", Util.getStackTraceString(e),
238238
"session", SessionHelper.getSessionAttributes());
239239
}
240240

@@ -253,14 +253,6 @@ private void renderSystemError(Throwable e) {
253253
}
254254

255255

256-
private String getStackTraceString(Throwable e) {
257-
StringWriter sw = new StringWriter();
258-
PrintWriter pw = new PrintWriter(sw);
259-
e.printStackTrace(pw);
260-
pw.flush();
261-
return sw.toString();
262-
}
263-
264256
private void renderSystemError(String template, String layout, int status, Throwable e) {
265257
try{
266258

@@ -278,7 +270,7 @@ private void renderSystemError(String template, String layout, int status, Throw
278270
if (requestedWith != null && requestedWith.equalsIgnoreCase("XMLHttpRequest")) {
279271
try {
280272

281-
RequestContext.getHttpResponse().getWriter().write(getStackTraceString(e));
273+
RequestContext.getHttpResponse().getWriter().write(Util.getStackTraceString(e));
282274
} catch (Exception ex) {
283275
logger.error("Failed to send error response to client", ex);
284276
}

0 commit comments

Comments
 (0)