How to show an error to user?

I've fixed an issue with deck loading. If a deck loaded at startup contains an unsuppored card, forge throwed an exception.
What is a correct way to imform user that some of his decks are not good to play with?
I've made this:
What is a correct way to imform user that some of his decks are not good to play with?
I've made this:
- Code: Select all
public void readAllDecks() {
// some code here
List<String> decksThatFailedToLoad = new ArrayList<String>();
files = deckDir.listFiles(DCKFileFilter);
for (File file : files) {
try {
Deck newDeck = readDeck(file);
deckMap.put(newDeck.getName(), newDeck);
} catch (NoSuchElementException ex) {
String message = String.format("%s failed to load because ---- %s", file.getName(), ex.getMessage());
decksThatFailedToLoad.add(message);
}
}
if (!decksThatFailedToLoad.isEmpty()) {
JOptionPane.showMessageDialog(null, StringUtils.join(decksThatFailedToLoad, System.getProperty("line.separator")),
"Some of your decks were not loaded.", JOptionPane.WARNING_MESSAGE);
}
//here was some more code
}