From 8d3dd3f012f622e71564e32df1686a564a9c29f7 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Thu, 8 Jun 2023 22:56:22 +0200 Subject: [PATCH] added filename to Exceptions thrown by HashingInputStream --- .../core/digest/HashingInputStream.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/digest/HashingInputStream.java b/src/main/java/net/szum123321/textile_backup/core/digest/HashingInputStream.java index a288b25..ca88205 100644 --- a/src/main/java/net/szum123321/textile_backup/core/digest/HashingInputStream.java +++ b/src/main/java/net/szum123321/textile_backup/core/digest/HashingInputStream.java @@ -52,7 +52,12 @@ public class HashingInputStream extends FilterInputStream { @Override public int read(byte @NotNull [] b, int off, int len) throws IOException { - int i = in.read(b, off, len); + int i; + try { + i = in.read(b, off, len); + } catch(IOException e) { + throw new IOException("An exception occurred while trying to access: [" + path.toString() + "]", e); + } if(i != -1) { hash.update(b, off, i); bytesWritten += i; @@ -62,7 +67,12 @@ public class HashingInputStream extends FilterInputStream { @Override public int read() throws IOException { - int i = in.read(); + int i; + try { + i = in.read(); + } catch(IOException e) { + throw new IOException("An exception occurred while trying to access: [" + path.toString() + "]", e); + } if(i != -1) { hash.update(i); bytesWritten++;