merge with branch issue-333

This commit is contained in:
Sebastian Sdorra
2013-04-02 21:58:42 +02:00
2 changed files with 45 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ package sonia.scm.web;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.common.io.Closeables;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -61,6 +62,7 @@ import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -294,6 +296,10 @@ public class HgHookCallbackServlet extends HttpServlet
response.sendError(HttpServletResponse.SC_NOT_FOUND); response.sendError(HttpServletResponse.SC_NOT_FOUND);
} }
catch (Exception ex)
{
sendError(response, ex);
}
} }
/** /**
@@ -350,6 +356,39 @@ public class HgHookCallbackServlet extends HttpServlet
} }
} }
/**
* Method description
*
*
* @param response
* @param ex
*
* @throws IOException
*/
private void sendError(HttpServletResponse response, Exception ex)
throws IOException
{
logger.warn("hook ended with exception", ex);
response.setStatus(HttpServletResponse.SC_CONFLICT);
String msg = ex.getMessage();
if (msg != null)
{
PrintWriter writer = null;
try
{
writer = response.getWriter();
writer.println(msg);
}
finally
{
Closeables.closeQuietly(writer);
}
}
}
//~--- get methods ---------------------------------------------------------- //~--- get methods ----------------------------------------------------------
/** /**

View File

@@ -54,6 +54,12 @@ def callHookUrl(ui, repo, hooktype, node):
abort = False abort = False
else: else:
ui.warn( "ERROR: scm-hook failed with error code " + str(conn.code) + "\n" ) ui.warn( "ERROR: scm-hook failed with error code " + str(conn.code) + "\n" )
except urllib2.URLError, e:
msg = e.read();
if len(msg) > 0:
ui.warn( "ERROR: " + msg)
else:
ui.warn( "ERROR: scm-hook failed with error code " + str(e.getcode()) + "\n" )
except ValueError: except ValueError:
ui.warn( "scm-hook failed with an exception\n" ) ui.warn( "scm-hook failed with an exception\n" )
return abort return abort