Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
report error/exit if kam cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
abargnesi committed Nov 24, 2014
1 parent 59ff4ce commit ac7de5b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ private ExportFormat determineType() {
}

/**
* If {@link determineType} returns {@code null} then this function may be able to determine
* If {@link #determineType} returns {@code null} then this function may be able to determine
* an appropriate type of KAM file from its file extension.
* @param file
* @return
Expand Down Expand Up @@ -571,6 +571,10 @@ private void runExportCommand(final String kamName, String outputFilename,
setUp();
kam = kAMStore.getKam(kamName);

if (kam == null) {
fatal(format("No KAM named \"%s\" exists in the catalog", kamName));
}

// establish a default if output path is not set
if (outputFilename == null) {
outputFilename =
Expand Down Expand Up @@ -625,6 +629,7 @@ private void runExportCommand(final String kamName, String outputFilename,
}
}


private static String defaultExtension(final ExportFormat type) {
switch (type) {
case PORTABLE_KAM:
Expand All @@ -650,6 +655,9 @@ private void runSummarizeCommand(final String kamName,
if (kamName != null) {
// Look up the requested KAM and summarize.
kam = kAMStore.getKam(kamName);
if (kam == null) {
fatal(format("No KAM named \"%s\" exists in the catalog", kamName));
}
KamSummarizer summarizer = new KamSummarizer(reportable);
KamSummary summary = KamSummarizer.summarizeKam(kAMStore, kam);
summarizer.printKamSummary(kAMStore, summary);
Expand Down Expand Up @@ -862,7 +870,6 @@ private void runRenameCommand(final String oldKamName,
/*
* The following are utility methods used for usage and error messages:
*/

private static String showCommandAliases() {
final Command[] commands = Command.values();
StringBuilder sb = new StringBuilder();
Expand Down

0 comments on commit ac7de5b

Please sign in to comment.