01: package com.icesoft.faces.webapp.http.common.standard;
02:
03: import com.icesoft.faces.webapp.http.common.Response;
04: import com.icesoft.faces.webapp.http.common.ResponseHandler;
05:
06: import java.io.PrintWriter;
07:
08: public class ServerErrorHandler implements ResponseHandler {
09: private Throwable throwable;
10:
11: public ServerErrorHandler(Throwable t) {
12: throwable = t;
13: }
14:
15: public void respond(Response response) throws Exception {
16: response.setStatus(500);
17: response.setHeader("Content-Type", "text/plain;charset=UTF-8");
18: PrintWriter writer = new PrintWriter(response.writeBody());
19: throwable.printStackTrace(writer);
20: writer.flush();
21: }
22: }
|