// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.responders;

import fitnesse.FitNesseContext;
import fitnesse.Responder;
import fitnesse.http.Request;
import fitnesse.http.Response;
import fitnesse.http.SimpleResponse;
import fitnesse.html.template.HtmlPage;

public class ErrorResponder implements Responder {
  private Exception exception;
  private String message;
  private int statusCode;

  public ErrorResponder(Exception e) {
    exception = e;
    statusCode = 400;
  }

  public ErrorResponder(String message) {
    this(message, 400);
  }

  public ErrorResponder(String message, int statusCode) {
    this.message = message;
    this.statusCode = statusCode;
  }

  @Override
  public Response makeResponse(FitNesseContext context, Request request) {
    SimpleResponse response = new SimpleResponse(statusCode);
    HtmlPage html = context.pageFactory.newPage();
    html.addTitles("Error Occurred");
    html.setMainTemplate("error");
    html.put("exception", exception);
    if (exception != null)
      html.put("exception", exception);
    if (message != null)
      html.put("message", message);
    response.setContent(html.html());

    return response;
  }

  public static String makeExceptionString(Throwable e) {
    StringBuilder buffer = new StringBuilder();
    buffer.append(e.toString()).append("\n");
    for (StackTraceElement stackTraceElement : e.getStackTrace()) {
      buffer.append("\t" + stackTraceElement).append("\n");
    }

    return buffer.toString();
  }
}

@@ -1365,18 +1365,19 @@
 ilder bu
-ff
+ild
 er = new
@@ -1396,26 +1396,27 @@
 er();%0A    bu
-ff
+ild
 er.append(e.
@@ -1517,18 +1517,19 @@
       bu
-ff
+ild
 er.appen
@@ -1538,11 +1538,32 @@
 %22%5Ct%22
- + 
+)%0A              .append(
 stac
@@ -1576,16 +1576,31 @@
 Element)
+%0A              
 .append(
@@ -1630,10 +1630,11 @@
 n bu
-ff
+ild
 er.t

Use StringBuilder.append instead of concatenating Strings for all Strings in this method