1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 09:49:19 +02:00

more debug info in CachedCharStorageException

This commit is contained in:
Nikolay Pultsin 2015-08-23 23:14:08 +01:00
parent 04718cc9fe
commit 03d954edfc
2 changed files with 9 additions and 4 deletions

View file

@ -55,7 +55,7 @@ public final class CachedCharStorage {
File file = new File(fileName(index));
int size = (int)file.length();
if (size < 0) {
throw new CachedCharStorageException("Error during reading " + fileName(index));
throw new CachedCharStorageException("Error during reading " + fileName(index) + "; size = " + size);
}
block = new char[size / 2];
InputStreamReader reader =
@ -63,12 +63,13 @@ public final class CachedCharStorage {
new FileInputStream(file),
"UTF-16LE"
);
if (reader.read(block) != block.length) {
throw new CachedCharStorageException("Error during reading " + fileName(index));
final int rd = reader.read(block);
if (rd != block.length) {
throw new CachedCharStorageException("Error during reading " + fileName(index) + "; " + rd + " != " + block.length);
}
reader.close();
} catch (IOException e) {
throw new CachedCharStorageException("Error during reading " + fileName(index));
throw new CachedCharStorageException("Error during reading " + fileName(index), e);
}
myArray.set(index, new WeakReference<char[]>(block));
}

View file

@ -25,4 +25,8 @@ public final class CachedCharStorageException extends RuntimeException {
public CachedCharStorageException(String message) {
super(message);
}
public CachedCharStorageException(String message, Throwable cause) {
super(message, cause);
}
}