Skip to content

Commit

Permalink
Add some exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
twanvl committed Sep 10, 2018
1 parent eec96bc commit 8bdf9b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/main/java/sts_exporter/CardExportData.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,9 @@ private static final ArrayList<String> words(String str) {

@Override
public int compareTo(CardExportData that) {
if (card.color != that.card.color) return card.color.compareTo(that.card.color);
if (card.rarity != that.card.rarity) return card.rarity.compareTo(that.card.rarity);
return name.compareTo(that.name);
int result = card.color.compareTo(that.card.color);
if (result == 0) result = card.rarity.compareTo(that.card.rarity);
if (result == 0) result = name.compareTo(that.name);
return result;
}
}
10 changes: 7 additions & 3 deletions src/main/java/sts_exporter/CreatureExportData.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,13 @@ public static ArrayList<AbstractPlayer> getAllPlayers() {
Method createCharacter = CardCrawlGame.class.getDeclaredMethod("createCharacter", AbstractPlayer.PlayerClass.class);
createCharacter.setAccessible(true);
for (AbstractPlayer.PlayerClass playerClass : AbstractPlayer.PlayerClass.values()) {
AbstractPlayer p = (AbstractPlayer)createCharacter.invoke(null, playerClass);
p.name = p.title;
players.add(p);
try {
AbstractPlayer p = (AbstractPlayer)createCharacter.invoke(null, playerClass);
p.name = p.title;
players.add(p);
} catch (Exception e) {
Exporter.logger.error("Exception occured when creating character", e);
}
}
} catch (Exception e) {
Exporter.logger.error("Exception occured when getting createCharacter method", e);
Expand Down

0 comments on commit 8bdf9b6

Please sign in to comment.