git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 2/5] Allow exceptions to be created with integer type codes
Date: Fri, 12 Jun 2009 16:00:16 -0700	[thread overview]
Message-ID: <1244847619-7364-3-git-send-email-spearce@spearce.org> (raw)
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

  reply	other threads:[~2009-06-12 23:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-12 23:00 [JGIT PATCH 0/5] Fix major performance problems in UploadPack Shawn O. Pearce
2009-06-12 23:00 ` [JGIT PATCH 1/5] Make RevTag getObject(), getName() final to prevent overrides Shawn O. Pearce
2009-06-12 23:00   ` Shawn O. Pearce [this message]
2009-06-12 23:00     ` [JGIT PATCH 3/5] Unify RevWalk parsing code to be more consistent across types Shawn O. Pearce
2009-06-12 23:00       ` [JGIT PATCH 4/5] Change RevObject dispose() semantics to avoid reparses Shawn O. Pearce
2009-06-12 23:00         ` [JGIT PATCH 5/5] UploadPack: Only recompute okToGiveUp() if bases changed Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1244847619-7364-3-git-send-email-spearce@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg@dewire.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).