changes to error handling

This commit is contained in:
rusefi 2017-03-01 15:04:35 -05:00
parent 889a4eb772
commit d405983ab8
1 changed files with 6 additions and 2 deletions

View File

@ -30,10 +30,14 @@ public class ConfigurationImageFile {
byte[] header = new byte[ConfigurationImage.BIN_HEADER.length()];
int result = fis.read(header);
if (result != header.length)
if (result != header.length) {
System.err.println("Error reading header bytes, got " + result);
return null;
if (!Arrays.equals(header, ConfigurationImage.BIN_HEADER.getBytes()))
}
if (!Arrays.equals(header, ConfigurationImage.BIN_HEADER.getBytes())) {
System.err.println("Header mismatch");
return null;
}
ConfigurationImage image = new ConfigurationImage(contentSize);
result = fis.read(image.getContent());
return result == image.getContent().length ? image : null;