diff src/org/tmatesoft/hg/core/HgCatCommand.java @ 423:9c9c442b5f2e

Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 23 Mar 2012 22:51:18 +0100
parents 0ae53c32ecef
children 31a89587eb04
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgCatCommand.java	Fri Mar 23 21:26:01 2012 +0100
+++ b/src/org/tmatesoft/hg/core/HgCatCommand.java	Fri Mar 23 22:51:18 2012 +0100
@@ -24,6 +24,9 @@
 import java.nio.ByteBuffer;
 
 import org.tmatesoft.hg.repo.HgDataFile;
+import org.tmatesoft.hg.repo.HgInvalidControlFileException;
+import org.tmatesoft.hg.repo.HgInvalidFileException;
+import org.tmatesoft.hg.repo.HgInvalidRevisionException;
 import org.tmatesoft.hg.repo.HgRepository;
 import org.tmatesoft.hg.util.Adaptable;
 import org.tmatesoft.hg.util.ByteChannel;
@@ -161,6 +164,7 @@
 			int csetRev = repo.getChangelog().getRevisionIndex(cset);
 			Nodeid toExtract = null;
 			do {
+				// TODO post-1.0 perhaps, HgChangesetFileSneaker may come handy?
 				toExtract = repo.getManifest().getFileRevision(csetRev, file);
 				if (toExtract == null) {
 					if (dataFile.isCopy()) {
@@ -172,7 +176,8 @@
 				}
 			} while (toExtract == null);
 			if (toExtract == null) {
-				throw new HgBadStateException(String.format("File %s nor its origins were not known at repository %s revision", file, cset.shortNotation()));
+				// TODO explicit FileNotFoundException?
+				throw new HgBadArgumentException(String.format("File %s nor its origins were not known at repository %s revision", file, cset.shortNotation()), null);
 			}
 			revToExtract = dataFile.getRevisionIndex(toExtract);
 		} else if (revision != null) {