mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
Merged in feature/errorhandling (pull request #99)
Feature Error Handling
This commit is contained in:
@@ -272,7 +272,7 @@ public class AbstractHgHandler
|
||||
} catch (JAXBException ex) {
|
||||
logger.error("could not parse result", ex);
|
||||
|
||||
throw new InternalRepositoryException("could not parse result", ex);
|
||||
throw new InternalRepositoryException(repository, "could not parse result", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ package sonia.scm.repository.spi;
|
||||
import com.aragost.javahg.commands.ExecutionException;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Closeables;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.ContextEntry;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.web.HgUtil;
|
||||
@@ -46,6 +49,8 @@ import java.io.OutputStream;
|
||||
|
||||
public class HgCatCommand extends AbstractCommand implements CatCommand {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HgCatCommand.class);
|
||||
|
||||
HgCatCommand(HgCommandContext context, Repository repository) {
|
||||
super(context, repository);
|
||||
}
|
||||
@@ -70,7 +75,8 @@ public class HgCatCommand extends AbstractCommand implements CatCommand {
|
||||
try {
|
||||
return cmd.execute(request.getPath());
|
||||
} catch (ExecutionException e) {
|
||||
throw new InternalRepositoryException(e);
|
||||
log.error("could not execute cat command", e);
|
||||
throw new InternalRepositoryException(ContextEntry.ContextBuilder.entity(getRepository()), "could not execute cat command", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class HgIncomingCommand extends AbstractCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InternalRepositoryException("could not execute incoming command", ex);
|
||||
throw new InternalRepositoryException(getRepository(), "could not execute incoming command", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class HgOutgoingCommand extends AbstractCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InternalRepositoryException("could not execute outgoing command", ex);
|
||||
throw new InternalRepositoryException(getRepository(), "could not execute outgoing command", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class HgPullCommand extends AbstractHgPushOrPullCommand
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not execute push command", ex);
|
||||
throw new InternalRepositoryException(getRepository(), "could not execute push command", ex);
|
||||
}
|
||||
|
||||
return new PullResponse(result.size());
|
||||
|
||||
@@ -97,7 +97,7 @@ public class HgPushCommand extends AbstractHgPushOrPullCommand
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not execute push command", ex);
|
||||
throw new InternalRepositoryException(getRepository(), "could not execute push command", ex);
|
||||
}
|
||||
|
||||
return new PushResponse(result.size());
|
||||
|
||||
@@ -44,11 +44,11 @@ import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.NotFoundException;
|
||||
import sonia.scm.repository.HgContext;
|
||||
import sonia.scm.repository.HgHookManager;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.RepositoryHookType;
|
||||
import sonia.scm.repository.RepositoryNotFoundException;
|
||||
import sonia.scm.repository.RepositoryUtil;
|
||||
import sonia.scm.repository.api.HgHookMessage;
|
||||
import sonia.scm.repository.api.HgHookMessage.Severity;
|
||||
@@ -275,17 +275,11 @@ public class HgHookCallbackServlet extends HttpServlet
|
||||
|
||||
printMessages(response, context);
|
||||
}
|
||||
catch (RepositoryNotFoundException ex)
|
||||
catch (NotFoundException ex)
|
||||
{
|
||||
if (logger.isErrorEnabled())
|
||||
{
|
||||
logger.error("could not find repository with id {}", id);
|
||||
logger.error(ex.getMessage());
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("repository not found", ex);
|
||||
}
|
||||
}
|
||||
logger.trace("repository not found", ex);
|
||||
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.junit.Test;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.Modifications;
|
||||
import sonia.scm.repository.RevisionNotFoundException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -151,7 +150,7 @@ public class HgLogCommandTest extends AbstractHgCommandTestBase
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommit() throws IOException, RevisionNotFoundException {
|
||||
public void testGetCommit() throws IOException {
|
||||
HgLogCommand command = createComamnd();
|
||||
String revision = "a9bacaf1b7fa0cebfca71fed4e59ed69a6319427";
|
||||
Changeset c =
|
||||
|
||||
Reference in New Issue
Block a user