mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
merge with branch issue-333
This commit is contained in:
@@ -35,6 +35,7 @@ package sonia.scm.web;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -61,6 +62,7 @@ import sonia.scm.util.Util;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -294,6 +296,10 @@ public class HgHookCallbackServlet extends HttpServlet
|
||||
|
||||
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 ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,6 +54,12 @@ def callHookUrl(ui, repo, hooktype, node):
|
||||
abort = False
|
||||
else:
|
||||
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:
|
||||
ui.warn( "scm-hook failed with an exception\n" )
|
||||
return abort
|
||||
|
||||
Reference in New Issue
Block a user