Fix potential issues with reporting expections

This commit is contained in:
nathan 2017-08-05 00:48:35 +02:00
parent 305b76447c
commit f0331e8cc8
2 changed files with 10 additions and 2 deletions

View File

@ -323,7 +323,11 @@ class StorageBase {
return readRecordData;
} catch (Exception e) {
String message = e.getMessage().substring(0,e.getMessage().indexOf(OS.LINE_SEPARATOR));
String message = e.getMessage();
int index = message.indexOf(OS.LINE_SEPARATOR);
if (index > -1) {
message = message.substring(0, index);
}
if (logger != null) {
logger.error("Error reading data from disk: {}", message);
}

View File

@ -256,7 +256,11 @@ class StorageSystem {
storage = new DiskStorage(this.file, this.serializationManager, this.readOnly, this.saveDelayInMilliseconds, this.logger);
storages.put(this.file, storage);
} catch (IOException e) {
String message = e.getMessage().substring(0,e.getMessage().indexOf(OS.LINE_SEPARATOR));
String message = e.getMessage();
int index = message.indexOf(OS.LINE_SEPARATOR);
if (index > -1) {
message = message.substring(0, index);
}
if (logger != null) {
logger.error("Unable to open storage file at {}. {}", this.file, message);
}