Browse Source

Refactor Git API exceptions to a new package

Create a new 'org.eclipse.jgit.api.errors' package to contain
exceptions related to using the Git porcelain API.

Change-Id: Iac1781bd74fbd520dffac9d347616c3334994470
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
stable-0.9
Chris Aniszczyk 14 years ago committed by Shawn O. Pearce
parent
commit
38327a54a8
  1. 1
      org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
  2. 8
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
  3. 1
      org.eclipse.jgit.test/META-INF/MANIFEST.MF
  4. 1
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
  5. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java
  6. 1
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
  7. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java
  8. 3
      org.eclipse.jgit/META-INF/MANIFEST.MF
  9. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java
  10. 8
      org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
  11. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
  12. 11
      org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
  13. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java
  14. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java
  15. 17
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ConcurrentRefUpdateException.java
  16. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/GitAPIException.java
  17. 7
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidMergeHeadsException.java
  18. 7
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidTagNameException.java
  19. 13
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/JGitInternalException.java
  20. 13
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoFilepatternException.java
  21. 13
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoHeadException.java
  22. 13
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoMessageException.java
  23. 13
      org.eclipse.jgit/src/org/eclipse/jgit/api/errors/WrongRepositoryStateException.java

1
org.eclipse.jgit.pgm/META-INF/MANIFEST.MF

@ -7,6 +7,7 @@ Bundle-Vendor: %provider_name
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.eclipse.jgit.api;version="[0.9.0,0.10.0)",
org.eclipse.jgit.api.errors;version="[0.9.0,0.10.0)",
org.eclipse.jgit.awtui;version="[0.9.0,0.10.0)",
org.eclipse.jgit.diff;version="[0.9.0,0.10.0)",
org.eclipse.jgit.dircache;version="[0.9.0,0.10.0)",

8
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java

@ -38,11 +38,11 @@
package org.eclipse.jgit.pgm;
import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.JGitInternalException;
import org.eclipse.jgit.api.NoHeadException;
import org.eclipse.jgit.api.NoMessageException;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevCommit;

1
org.eclipse.jgit.test/META-INF/MANIFEST.MF

@ -11,6 +11,7 @@ Import-Package: junit.framework;version="[4.0.0,5.0.0)",
junit.textui;version="[3.8.2,4.0.0)",
org.eclipse.jgit;version="[0.9.0,0.10.0)",
org.eclipse.jgit.api;version="[0.9.0,0.10.0)",
org.eclipse.jgit.api.errors;version="[0.9.0,0.10.0)",
org.eclipse.jgit.awtui;version="[0.9.0,0.10.0)",
org.eclipse.jgit.console;version="[0.9.0,0.10.0)",
org.eclipse.jgit.diff;version="[0.9.0,0.10.0)",

1
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java

@ -48,6 +48,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
import org.eclipse.jgit.dircache.DirCacheEntry;

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java

@ -47,6 +47,12 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.errors.UnmergedPathException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;

1
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java

@ -48,6 +48,7 @@ import java.io.IOException;
import java.util.Iterator;
import org.eclipse.jgit.api.MergeResult.MergeStatus;
import org.eclipse.jgit.api.errors.InvalidMergeHeadsException;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java

@ -42,6 +42,12 @@
*/
package org.eclipse.jgit.api;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.InvalidTagNameException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.errors.UnmergedPathException;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.revwalk.RevCommit;

3
org.eclipse.jgit/META-INF/MANIFEST.MF

@ -7,10 +7,11 @@ Bundle-Localization: plugin
Bundle-Vendor: %provider_name
Export-Package: org.eclipse.jgit;version="0.9.0",
org.eclipse.jgit.api;version="0.9.0",
org.eclipse.jgit.api.errors;version="0.9.0",
org.eclipse.jgit.diff;version="0.9.0",
org.eclipse.jgit.dircache;version="0.9.0",
org.eclipse.jgit.events;version="0.9.0",
org.eclipse.jgit.errors;version="0.9.0",
org.eclipse.jgit.events;version="0.9.0",
org.eclipse.jgit.fnmatch;version="0.9.0",
org.eclipse.jgit.ignore;version="0.9.0",
org.eclipse.jgit.lib;version="0.9.0",

2
org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java

@ -49,6 +49,8 @@ import java.util.Collection;
import java.util.LinkedList;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuildIterator;
import org.eclipse.jgit.dircache.DirCacheBuilder;

8
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

@ -48,6 +48,12 @@ import java.util.LinkedList;
import java.util.List;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.errors.UnmergedPathException;
import org.eclipse.jgit.lib.CommitBuilder;
@ -57,9 +63,9 @@ import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.RefUpdate.Result;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.lib.RefUpdate.Result;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;

2
org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java

@ -46,6 +46,8 @@ import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.AnyObjectId;

11
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java

@ -52,16 +52,23 @@ import java.util.Map;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.api.MergeResult.MergeStatus;
import org.eclipse.jgit.api.errors.CheckoutConflictException;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.InvalidMergeHeadsException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdRef;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Ref.Storage;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.RefUpdate.Result;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.merge.MergeStrategy;
import org.eclipse.jgit.merge.ResolveMerger;
import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;

4
org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java

@ -46,6 +46,10 @@ import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.InvalidTagNameException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;

2
org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutConflictException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
import java.util.LinkedList;
import java.util.List;

17
org.eclipse.jgit/src/org/eclipse/jgit/api/ConcurrentRefUpdateException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ConcurrentRefUpdateException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
import java.text.MessageFormat;
@ -54,7 +54,13 @@ public class ConcurrentRefUpdateException extends GitAPIException {
private RefUpdate.Result rc;
private Ref ref;
ConcurrentRefUpdateException(String message, Ref ref,
/**
* @param message
* @param ref
* @param rc
* @param cause
*/
public ConcurrentRefUpdateException(String message, Ref ref,
RefUpdate.Result rc, Throwable cause) {
super((rc == null) ? message : message + ". "
+ MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc), cause);
@ -62,7 +68,12 @@ public class ConcurrentRefUpdateException extends GitAPIException {
this.ref = ref;
}
ConcurrentRefUpdateException(String message, Ref ref,
/**
* @param message
* @param ref
* @param rc
*/
public ConcurrentRefUpdateException(String message, Ref ref,
RefUpdate.Result rc) {
super((rc == null) ? message : message + ". "
+ MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc));

2
org.eclipse.jgit/src/org/eclipse/jgit/api/GitAPIException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/GitAPIException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
/**
* Superclass of all exceptions thrown by the API classes in

7
org.eclipse.jgit/src/org/eclipse/jgit/api/InvalidMergeHeadsException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidMergeHeadsException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
/**
@ -47,7 +47,10 @@ package org.eclipse.jgit.api;
public class InvalidMergeHeadsException extends GitAPIException {
private static final long serialVersionUID = 1L;
InvalidMergeHeadsException(String msg) {
/**
* @param msg
*/
public InvalidMergeHeadsException(String msg) {
super(msg);
}
}

7
org.eclipse.jgit/src/org/eclipse/jgit/api/InvalidTagNameException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidTagNameException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
/**
* Exception thrown when a tag command was called with an invalid tag name (or
@ -44,7 +44,10 @@ package org.eclipse.jgit.api;
public class InvalidTagNameException extends GitAPIException {
private static final long serialVersionUID = 1L;
InvalidTagNameException(String msg) {
/**
* @param msg
*/
public InvalidTagNameException(String msg) {
super(msg);
}
}

13
org.eclipse.jgit/src/org/eclipse/jgit/api/JGitInternalException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/JGitInternalException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
/**
* Exception thrown when during command execution a low-level exception from the
@ -59,11 +59,18 @@ package org.eclipse.jgit.api;
public class JGitInternalException extends RuntimeException {
private static final long serialVersionUID = 1L;
JGitInternalException(String message, Throwable cause) {
/**
* @param message
* @param cause
*/
public JGitInternalException(String message, Throwable cause) {
super(message, cause);
}
JGitInternalException(String message) {
/**
* @param message
*/
public JGitInternalException(String message) {
super(message);
}
}

13
org.eclipse.jgit/src/org/eclipse/jgit/api/NoFilepatternException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoFilepatternException.java

@ -37,7 +37,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
/**
* Exception thrown when the options given to a command don't include a
@ -47,11 +47,18 @@ public class NoFilepatternException extends GitAPIException {
private static final long serialVersionUID = 1L;
NoFilepatternException(String message, Throwable cause) {
/**
* @param message
* @param cause
*/
public NoFilepatternException(String message, Throwable cause) {
super(message, cause);
}
NoFilepatternException(String message) {
/**
* @param message
*/
public NoFilepatternException(String message) {
super(message);
}

13
org.eclipse.jgit/src/org/eclipse/jgit/api/NoHeadException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoHeadException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
/**
* Exception thrown when a command expected the {@code HEAD} reference to exist
@ -44,11 +44,18 @@ package org.eclipse.jgit.api;
public class NoHeadException extends GitAPIException {
private static final long serialVersionUID = 1L;
NoHeadException(String message, Throwable cause) {
/**
* @param message
* @param cause
*/
public NoHeadException(String message, Throwable cause) {
super(message, cause);
}
NoHeadException(String message) {
/**
* @param message
*/
public NoHeadException(String message) {
super(message);
}
}

13
org.eclipse.jgit/src/org/eclipse/jgit/api/NoMessageException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoMessageException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
/**
* Exception thrown when the options given to a command don't include a
@ -46,11 +46,18 @@ package org.eclipse.jgit.api;
public class NoMessageException extends GitAPIException {
private static final long serialVersionUID = 1L;
NoMessageException(String message, Throwable cause) {
/**
* @param message
* @param cause
*/
public NoMessageException(String message, Throwable cause) {
super(message, cause);
}
NoMessageException(String message) {
/**
* @param message
*/
public NoMessageException(String message) {
super(message);
}
}

13
org.eclipse.jgit/src/org/eclipse/jgit/api/WrongRepositoryStateException.java → org.eclipse.jgit/src/org/eclipse/jgit/api/errors/WrongRepositoryStateException.java

@ -35,7 +35,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.api;
package org.eclipse.jgit.api.errors;
/**
* Exception thrown when the state of the repository doesn't allow the execution
@ -45,11 +45,18 @@ package org.eclipse.jgit.api;
public class WrongRepositoryStateException extends GitAPIException {
private static final long serialVersionUID = 1L;
WrongRepositoryStateException(String message, Throwable cause) {
/**
* @param message
* @param cause
*/
public WrongRepositoryStateException(String message, Throwable cause) {
super(message, cause);
}
WrongRepositoryStateException(String message) {
/**
* @param message
*/
public WrongRepositoryStateException(String message) {
super(message);
}
}
Loading…
Cancel
Save