Merged in feature/errorhandling (pull request #99)

Feature Error Handling
This commit is contained in:
Sebastian Sdorra
2018-11-08 09:36:18 +00:00
139 changed files with 1122 additions and 2010 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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());

View File

@@ -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());

View File

@@ -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);
}

View File

@@ -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 =