1   package com.atlassian.selenium;
2   
3   import com.thoughtworks.selenium.HttpCommandProcessor;
4   import org.apache.log4j.Logger;
5   
6   /**
7    * An Atlassian HttpCommand processor to dump the HTML if there are any errors.
8    */
9   public class HtmlDumpingHttpCommandProcessor extends HttpCommandProcessor
10  {
11      private static final Logger log = Logger.getLogger(HtmlDumpingHttpCommandProcessor.class);
12  
13      public HtmlDumpingHttpCommandProcessor(String s, int i, String s1, String s2)
14      {
15          super(s, i, s1, s2);
16      }
17  
18      public String doCommand(String s, String[] strings)
19      {
20          try
21          {
22              return super.doCommand(s, strings);
23          }
24          catch (RuntimeException e)
25          {
26              log.error("Error executing command [" + s + "]", e);
27              log.error("---------------- HTML DUMP -------------\n\n\n");
28              log.error(super.doCommand("getHtmlSource", new String[0]));
29              log.error("\n\n\n----------- END HTML DUMP -----------");
30              throw e;
31          }
32      }
33  }