mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
improve exception handling
This commit is contained in:
@@ -66,12 +66,21 @@ import javax.xml.bind.JAXBException;
|
||||
public class AbstractHgHandler
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_NODE = "HG_NODE";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_PAGE_LIMIT = "SCM_PAGE_LIMIT";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_PAGE_START = "SCM_PAGE_START";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_PATH = "SCM_PATH";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_PENDING = "HG_PENDING";
|
||||
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_PYTHON_PATH = "SCM_PYTHON_PATH";
|
||||
|
||||
@@ -80,21 +89,12 @@ public class AbstractHgHandler
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_REVISION = "SCM_REVISION";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_PAGE_LIMIT = "SCM_PAGE_LIMIT";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_PAGE_START = "SCM_PAGE_START";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_REVISION_END = "SCM_REVISION_END";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_REVISION_START = "SCM_REVISION_START";
|
||||
|
||||
/** Field description */
|
||||
public static final String ENV_NODE = "HG_NODE";
|
||||
|
||||
/** the logger for AbstractHgHandler */
|
||||
private static final Logger logger =
|
||||
@@ -294,10 +294,11 @@ public class AbstractHgHandler
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
protected <T> T getResultFromScript(Class<T> resultType,
|
||||
String scriptResource)
|
||||
throws IOException
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
return getResultFromScript(resultType, scriptResource,
|
||||
new HashMap<String, String>());
|
||||
@@ -315,10 +316,11 @@ public class AbstractHgHandler
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
protected <T> T getResultFromScript(Class<T> resultType,
|
||||
String scriptResource, Map<String, String> extraEnv)
|
||||
throws IOException
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
Process p = createPythonProcess(extraEnv);
|
||||
T result = null;
|
||||
@@ -340,6 +342,8 @@ public class AbstractHgHandler
|
||||
catch (JAXBException ex)
|
||||
{
|
||||
logger.error("could not parse result", ex);
|
||||
|
||||
throw new RepositoryException("could not parse result", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -411,8 +415,8 @@ public class AbstractHgHandler
|
||||
if (context.isPending())
|
||||
{
|
||||
env.put(ENV_PENDING, directory.getAbsolutePath());
|
||||
|
||||
if ( extraEnv.containsKey( ENV_REVISION_START ) )
|
||||
|
||||
if (extraEnv.containsKey(ENV_REVISION_START))
|
||||
{
|
||||
env.put(ENV_NODE, extraEnv.get(ENV_REVISION_START));
|
||||
}
|
||||
|
||||
@@ -93,9 +93,11 @@ public class HgBlameViewer extends AbstractHgHandler implements BlameViewer
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public BlameResult getBlame(String revision, String path) throws IOException
|
||||
public BlameResult getBlame(String revision, String path)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
AssertUtil.assertIsNotEmpty(path);
|
||||
|
||||
|
||||
@@ -104,10 +104,11 @@ public class HgChangesetViewer extends AbstractHgHandler
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@Override
|
||||
public ChangesetPagingResult getChangesets(int start, int max)
|
||||
throws IOException
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
return getChangesets(String.valueOf(start), String.valueOf(max), null,
|
||||
null);
|
||||
@@ -125,10 +126,11 @@ public class HgChangesetViewer extends AbstractHgHandler
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public ChangesetPagingResult getChangesets(String pageStart,
|
||||
String pageLimit, String revisionStart, String revisionEnd)
|
||||
throws IOException
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
Map<String, String> env = new HashMap<String, String>();
|
||||
|
||||
@@ -150,9 +152,10 @@ public class HgChangesetViewer extends AbstractHgHandler
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public ChangesetPagingResult getChangesets(String startNode, String endNode)
|
||||
throws IOException
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
return getChangesets(null, null, startNode, endNode);
|
||||
}
|
||||
|
||||
@@ -33,15 +33,9 @@
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -56,10 +50,6 @@ public class HgRepositoryHookEvent extends AbstractRepositoryHookEvent
|
||||
/** Field description */
|
||||
public static final String REV_TIP = "tip";
|
||||
|
||||
/** the logger for HgRepositoryHookEvent */
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(HgRepositoryHookEvent.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -104,9 +94,9 @@ public class HgRepositoryHookEvent extends AbstractRepositoryHookEvent
|
||||
changesets = result.getChangesets();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.error("could not load changesets", ex);
|
||||
throw new RuntimeException("could not load changesets", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user