diff src/org/tmatesoft/hg/core/HgLogCommand.java @ 354:5f9073eabf06

Propagate errors with exceptions up to a end client
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 01 Dec 2011 05:21:40 +0100
parents a674b8590362
children 189dc6dc1c3e
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgLogCommand.java	Thu Dec 01 03:05:28 2011 +0100
+++ b/src/org/tmatesoft/hg/core/HgLogCommand.java	Thu Dec 01 05:21:40 2011 +0100
@@ -34,6 +34,7 @@
 import org.tmatesoft.hg.repo.HgChangelog;
 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
 import org.tmatesoft.hg.repo.HgDataFile;
+import org.tmatesoft.hg.repo.HgInternals;
 import org.tmatesoft.hg.repo.HgRepository;
 import org.tmatesoft.hg.repo.HgStatusCollector;
 import org.tmatesoft.hg.util.CancelSupport;
@@ -154,8 +155,10 @@
 	 * 
 	 * @param nid changeset revision
 	 * @return <code>this</code> for convenience
+	 * @throws HgInvalidRevisionException if supplied nodeid doesn't identify any revision from this revlog  
+	 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
 	 */
-	public HgLogCommand changeset(Nodeid nid) {
+	public HgLogCommand changeset(Nodeid nid) throws HgInvalidControlFileException, HgInvalidRevisionException {
 		// XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions.
 		final int csetLocal = repo.getChangelog().getLocalRevision(nid);
 		return range(csetLocal, csetLocal);
@@ -203,7 +206,7 @@
 	 * @throws IllegalArgumentException when inspector argument is null
 	 * @throws ConcurrentModificationException if this log command instance is already running
 	 */
-	public void execute(HgChangesetHandler handler) throws HgDataStreamException, HgCallbackTargetException, CancelledException {
+	public void execute(HgChangesetHandler handler) throws HgDataStreamException, HgInvalidControlFileException, HgCallbackTargetException, CancelledException {
 		if (handler == null) {
 			throw new IllegalArgumentException();
 		}
@@ -594,7 +597,13 @@
 			if (cs != null) {
 				return cs.getNodeid();
 			} else {
-				return repo.getChangelog().getRevision(changelogRevisionNumber);
+				try {
+					return repo.getChangelog().getRevision(changelogRevisionNumber);
+				} catch (HgException ex) {
+					HgInternals.getContext(repo).getLog().error(getClass(), ex, null);
+					// FIXME propagate, perhaps?
+					return Nodeid.NULL; // FIXME this is quick-n-dirty hack to move forward with introducing exceptions 
+				}
 			}
 		}
 	}