Skip to content

Commit

Permalink
Ensured roper handling of Metapath errors during validation. Resolves u…
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Jul 8, 2024
1 parent a5c9a72 commit e8d5580
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ public void generateMessage(boolean showStackTrace) {

if (message != null && !message.isEmpty()) {
logBuilder.log(message);
} else if (throwable != null && showStackTrace) {
} else if (showStackTrace && throwable != null) {
// log the throwable
logBuilder.log();
}
} // otherwise there is nothing to log
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import gov.nist.secauto.metaschema.cli.util.LoggingValidationHandler;
import gov.nist.secauto.metaschema.core.configuration.DefaultConfiguration;
import gov.nist.secauto.metaschema.core.configuration.IMutableConfiguration;
import gov.nist.secauto.metaschema.core.metapath.MetapathException;
import gov.nist.secauto.metaschema.core.model.IConstraintLoader;
import gov.nist.secauto.metaschema.core.model.MetaschemaException;
import gov.nist.secauto.metaschema.core.model.constraint.IConstraintSet;
Expand Down Expand Up @@ -191,7 +192,7 @@ public ExitStatus execute() {
try {
URI constraintUri = ObjectUtils.requireNonNull(UriUtils.toUri(arg, cwd));
constraintSets.add(constraintLoader.load(constraintUri));
} catch (IOException | MetaschemaException | URISyntaxException ex) {
} catch (IOException | MetaschemaException | MetapathException | URISyntaxException ex) {
return ExitCode.IO_ERROR.exitMessage("Unable to load constraint set '" + arg + "'.").withThrowable(ex);
}
}
Expand Down Expand Up @@ -271,6 +272,8 @@ public ExitStatus execute() {
return ExitCode.IO_ERROR.exitMessage(String.format("Unknown host for '%s'.", source)).withThrowable(ex);

} catch (IOException ex) {
return ExitCode.IO_ERROR.exit().withThrowable(ex);
} catch (MetapathException ex) {
return ExitCode.PROCESSING_ERROR.exit().withThrowable(ex);
}

Expand All @@ -285,7 +288,7 @@ public ExitStatus execute() {
sarifHandler.addFindings(validationResult.getFindings());
sarifHandler.write(sarifFile);
} catch (IOException ex) {
return ExitCode.PROCESSING_ERROR.exit().withThrowable(ex);
return ExitCode.IO_ERROR.exit().withThrowable(ex);
}
} else if (!validationResult.isPassing()) {
LOGGER.info("Validation identified the following issues:", source);
Expand Down

0 comments on commit e8d5580

Please sign in to comment.