Skip to content

Commit

Permalink
refs LibraryOfCongress#123 - fixed error message formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jscancella authored and Richard van Heest committed Feb 20, 2019
1 parent eff1c35 commit fc8ef90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package gov.loc.repository.bagit.exceptions;

import java.nio.file.Path;

import org.slf4j.helpers.MessageFormatter;

/**
* The payload directory is a required file. This class represents the error if it is not found.
*/
public class MissingPayloadDirectoryException extends Exception {
private static final long serialVersionUID = 1L;

public MissingPayloadDirectoryException(final String message){
super(message);
public MissingPayloadDirectoryException(final String message, final Path path){
super(MessageFormatter.format(message, path).getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static void checkPayloadDirectoryExists(final Bag bag) throws MissingPayl
final Path dataDir = PathUtils.getDataDir(bag);

if(!Files.exists(dataDir)){
throw new MissingPayloadDirectoryException(messages.getString("file_should_exist_error"));
throw new MissingPayloadDirectoryException(messages.getString("file_should_exist_error"), dataDir);
}
}

Expand Down

0 comments on commit fc8ef90

Please sign in to comment.