git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 2/5] Allow exceptions to be created with integer type codes

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jun 12, 2009, 23:00 UTC
Message-ID
<1244847619-7364-3-git-send-email-spearce@spearce.org>
In-Reply-To
<1244847619-7364-2-git-send-email-spearce@spearce.org>

This may be easier in some contexts where we have the type code we expect handy, but not the type string constant.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../jgit/errors/IncorrectObjectTypeException.java  |   13 +++++++++++++
 .../jgit/errors/MissingObjectException.java        |   12 ++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/IncorrectObjectTypeException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/IncorrectObjectTypeException.java
index a194f19..3af1f44 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/errors/IncorrectObjectTypeException.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/IncorrectObjectTypeException.java
@@ -40,6 +40,7 @@
 
 import java.io.IOException;
 
+import org.spearce.jgit.lib.Constants;
 import org.spearce.jgit.lib.ObjectId;
 
 /**
@@ -62,4 +63,16 @@
 	public IncorrectObjectTypeException(final ObjectId id, final String type) {
 		super("Object " + id.name() + " is not a " + type + ".");
 	}
+
+	/**
+	 * Construct and IncorrectObjectTypeException for the specified object id.
+	 *
+	 * Provide the type to make it easier to track down the problem.
+	 *
+	 * @param id SHA-1
+	 * @param type object type
+	 */
+	public IncorrectObjectTypeException(final ObjectId id, final int type) {
+		this(id, Constants.typeString(type));
+	}
 }
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/MissingObjectException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/MissingObjectException.java
index 37147c3..7b7b8f3 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/errors/MissingObjectException.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/MissingObjectException.java
@@ -40,6 +40,7 @@
 
 import java.io.IOException;
 
+import org.spearce.jgit.lib.Constants;
 import org.spearce.jgit.lib.ObjectId;
 
 /**
@@ -58,4 +59,15 @@
 	public MissingObjectException(final ObjectId id, final String type) {
 		super("Missing " + type + " " + id.name());
 	}
+
+	/**
+	 * Construct a MissingObjectException for the specified object id.
+	 * Expected type is reported to simplify tracking down the problem.
+	 *
+	 * @param id SHA-1
+	 * @param type object type
+	 */
+	public MissingObjectException(final ObjectId id, final int type) {
+		this(id, Constants.typeString(type));
+	}
 }
-- 
1.6.3.2.367.gf0de
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 3 of 6 in “Fix major performance problems in UploadPack”
  1. 0/5 Fix major performance problems in UploadPackShawn O. Pearce, Jun 12, 2009
  2. 1/5 Make RevTag getObject(), getName() final to prevent overridesShawn O. Pearce, Jun 12, 2009
  3. 2/5 Allow exceptions to be created with integer type codesShawn O. Pearce, Jun 12, 2009
  4. 3/5 Unify RevWalk parsing code to be more consistent across typesShawn O. Pearce, Jun 12, 2009
  5. 4/5 Change RevObject dispose() semantics to avoid reparsesShawn O. Pearce, Jun 12, 2009
  6. 5/5 UploadPack: Only recompute okToGiveUp() if bases changedShawn O. Pearce, Jun 12, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.