1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +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)); File file = new File(fileName(index));
int size = (int)file.length(); int size = (int)file.length();
if (size < 0) { 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]; block = new char[size / 2];
InputStreamReader reader = InputStreamReader reader =
@ -63,12 +63,13 @@ public final class CachedCharStorage {
new FileInputStream(file), new FileInputStream(file),
"UTF-16LE" "UTF-16LE"
); );
if (reader.read(block) != block.length) { final int rd = reader.read(block);
throw new CachedCharStorageException("Error during reading " + fileName(index)); if (rd != block.length) {
throw new CachedCharStorageException("Error during reading " + fileName(index) + "; " + rd + " != " + block.length);
} }
reader.close(); reader.close();
} catch (IOException e) { } 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)); myArray.set(index, new WeakReference<char[]>(block));
} }

View file

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