Skip to content

Commit

Permalink
Updated validation output on unexpected exceptions. Bumped jackson.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Hoffmann committed Jan 7, 2020
1 parent a72a123 commit 529ce40
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
<junit.platform.version>1.0.3</junit.platform.version>
<swagger.version>1.5.16</swagger.version>
<jersey.version>2.22.2</jersey.version>
<jackson.version>2.10.1</jackson.version>
<jackson.databind.version>2.10.1</jackson.databind.version>
<jackson.version>2.10.2</jackson.version>
<jackson.databind.version>2.10.2</jackson.databind.version>
<jodatime.version>2.9.9</jodatime.version>
<hibernate.validator.version>6.0.7.Final</hibernate.validator.version>
<slf4j.version>1.7.25</slf4j.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public List<ValidationMessage> validate(Path filepath,
parser = new MzTabFileParser(filepath.toFile());
MZTabErrorList errorList = parser.parse(
System.out, MZTabErrorType.findLevel(validationLevel), maxErrors);
errorList.convertToValidationMessages();
} catch (Exception e) {
log.error("Caught Exception in IsasValidator:", e);
ValidationMessage vm = new ValidationMessage();
Expand All @@ -79,7 +78,13 @@ public List<ValidationMessage> validate(Path filepath,
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
vm.setMessage(e.getMessage()!=null?e.getMessage():"Caught an Exception while parsing '"+filepath.getFileName()+"'. Please check your file's tabular structure and inspect further validation messages!" + "\n" +sw.toString());
StringBuilder message = new StringBuilder();
message.append("Basic validation failed for file '").append(filepath.getFileName()).append("'\n");
if (e.getMessage() != null) {
message.append(" with message: '").append(e.getMessage()).append("'\n");
}
message.append("Please check your file's structure and inspect further validation messages!\n");
vm.setMessage(message.toString());
validationResults.add(vm);
} finally {
if (parser != null) {
Expand All @@ -93,7 +98,7 @@ public List<ValidationMessage> validate(Path filepath,
List<ValidationMessage> messages = cvValidator.validate(parser.
getMZTabFile());
validationResults.addAll(Optional.ofNullable(messages).orElse(Collections.emptyList()));
} catch (JAXBException | IllegalArgumentException iae) {
} catch (Exception iae) {
log.error("Caught Exception in IsasValidator, semantic validation:", iae);
ValidationMessage vm = new ValidationMessage();
vm.setCategory(
Expand All @@ -102,7 +107,16 @@ public List<ValidationMessage> validate(Path filepath,
vm.setLineNumber(-1l);
vm.setMessageType(
ValidationMessage.MessageTypeEnum.ERROR);
vm.setMessage(iae.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
iae.printStackTrace(pw);
StringBuilder message = new StringBuilder();
message.append("Semantic validation failed for file '").append(filepath.getFileName()).append("'\n");
if (iae.getMessage() != null) {
message.append(" with message: '").append(iae.getMessage()).append("'\n");
}
message.append("Please check your file's structure and inspect further validation messages!\n");
vm.setMessage(message.toString());
validationResults.add(vm);
}
}
Expand Down

0 comments on commit 529ce40

Please sign in to comment.