mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
Add context to InternalRepositoryException
This commit is contained in:
@@ -55,6 +55,7 @@ import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.ContextEntry;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.web.GitUserAgentProvider;
|
||||
@@ -203,7 +204,7 @@ public final class GitUtil
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not fetch", ex);
|
||||
throw new InternalRepositoryException(ContextEntry.ContextBuilder.entity("remote", directory.toString()).in(remoteRepository), "could not fetch", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ public abstract class AbstractGitIncomingOutgoingCommand
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not execute incoming command", ex);
|
||||
throw new InternalRepositoryException(repository, "could not execute incoming command", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -200,13 +200,7 @@ public abstract class AbstractGitIncomingOutgoingCommand
|
||||
{
|
||||
if (e.getKey().startsWith(prefix))
|
||||
{
|
||||
if (ref != null)
|
||||
{
|
||||
throw new InternalRepositoryException("could not find remote branch");
|
||||
}
|
||||
|
||||
ref = e.getValue();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public abstract class AbstractGitPushOrPullCommand extends AbstractGitCommand
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not execute push/pull command", ex);
|
||||
throw new InternalRepositoryException(repository, "could not execute push/pull command", ex);
|
||||
}
|
||||
|
||||
return counter;
|
||||
|
||||
@@ -55,6 +55,8 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -108,9 +110,8 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
|
||||
|
||||
if (gitBlameResult == null)
|
||||
{
|
||||
throw new InternalRepositoryException(
|
||||
"could not create blame result for path ".concat(
|
||||
request.getPath()));
|
||||
throw new InternalRepositoryException(entity("path", request.getPath()).in(repository),
|
||||
"could not create blame result for path");
|
||||
}
|
||||
|
||||
List<BlameLine> blameLines = new ArrayList<BlameLine>();
|
||||
@@ -150,7 +151,7 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not create blame view", ex);
|
||||
throw new InternalRepositoryException(repository, "could not create blame view", ex);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -102,7 +102,7 @@ public class GitBranchesCommand extends AbstractGitCommand
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not read branches", ex);
|
||||
throw new InternalRepositoryException(repository, "could not read branches", ex);
|
||||
}
|
||||
|
||||
return branches;
|
||||
|
||||
@@ -254,7 +254,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not create change log", ex);
|
||||
throw new InternalRepositoryException(repository, "could not create change log", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class GitModificationsCommand extends AbstractGitCommand implements ModificationsCommand {
|
||||
@@ -26,7 +28,7 @@ public class GitModificationsCommand extends AbstractGitCommand implements Modif
|
||||
}
|
||||
|
||||
private Modifications createModifications(TreeWalk treeWalk, RevCommit commit, RevWalk revWalk, String revision)
|
||||
throws IOException, UnsupportedModificationTypeException {
|
||||
throws IOException {
|
||||
treeWalk.reset();
|
||||
treeWalk.setRecursive(true);
|
||||
if (commit.getParentCount() > 0) {
|
||||
@@ -73,12 +75,7 @@ public class GitModificationsCommand extends AbstractGitCommand implements Modif
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
log.error("could not open repository", ex);
|
||||
throw new InternalRepositoryException(ex);
|
||||
|
||||
} catch (UnsupportedModificationTypeException ex) {
|
||||
log.error("Unsupported modification type", ex);
|
||||
throw new InternalRepositoryException(ex);
|
||||
|
||||
throw new InternalRepositoryException(entity(repository), "could not open repository", ex);
|
||||
} finally {
|
||||
GitUtil.release(revWalk);
|
||||
GitUtil.close(gitRepository);
|
||||
@@ -100,7 +97,7 @@ public class GitModificationsCommand extends AbstractGitCommand implements Modif
|
||||
} else if (type == DiffEntry.ChangeType.DELETE) {
|
||||
modifications.getRemoved().add(entry.getOldPath());
|
||||
} else {
|
||||
throw new UnsupportedModificationTypeException(MessageFormat.format("The modification type: {0} is not supported.", type));
|
||||
throw new UnsupportedModificationTypeException(entity(repository), MessageFormat.format("The modification type: {0} is not supported.", type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new InternalRepositoryException("error durring pull", ex);
|
||||
throw new InternalRepositoryException(repository, "error during pull", ex);
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class GitTagsCommand extends AbstractGitCommand implements TagsCommand
|
||||
}
|
||||
catch (GitAPIException ex)
|
||||
{
|
||||
throw new InternalRepositoryException("could not read tags from repository", ex);
|
||||
throw new InternalRepositoryException(repository, "could not read tags from repository", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import sonia.scm.ContextEntry;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
|
||||
public class UnsupportedModificationTypeException extends InternalRepositoryException {
|
||||
public UnsupportedModificationTypeException(String message) {
|
||||
super(message);
|
||||
public UnsupportedModificationTypeException(ContextEntry.ContextBuilder entity, String message) {
|
||||
super(entity, message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user