[JGIT PATCH 5/5] Include the file path when FileBasedConfig.load throws an exception

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This may help an end-user debug the problem, if they know what file
the error occurred in.  We have to wrap the exception here because
the methods throwing the original error do not have access to the
file path, and cannot include it in the message.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/FileBasedConfig.java  |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java b/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java
index adf85c6..518b31d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/FileBasedConfig.java
@@ -98,6 +98,12 @@ public void load() throws IOException, ConfigInvalidException {
 			fromText(RawParseUtils.decode(NB.readFully(getFile())));
 		} catch (FileNotFoundException noFile) {
 			clear();
+		} catch (IOException e) {
+			final IOException e2 = new IOException("Cannot read " + getFile());
+			e2.initCause(e);
+			throw e2;
+		} catch (ConfigInvalidException e) {
+			throw new ConfigInvalidException("Cannot read " + getFile(), e);
 		}
 	}
 
-- 
1.6.4.rc3.201.gd9d59

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]